2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.containers;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.inventory.Container;
|
2021-09-30 21:44:30 -05:00
|
|
|
import net.minecraft.inventory.IInventory;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.util.MathHelper;
|
2021-09-30 21:44:30 -05:00
|
|
|
import noppes.npcs.scripted.IContainer;
|
|
|
|
|
import noppes.npcs.scripted.ScriptContainer;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public class ContainerNpcInterface extends Container{
|
|
|
|
|
private int posX, posZ;
|
2021-09-30 21:44:30 -05:00
|
|
|
public EntityPlayer player;
|
|
|
|
|
public IContainer scriptContainer;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public ContainerNpcInterface(EntityPlayer player){
|
|
|
|
|
posX = MathHelper.floor_double(player.posX);
|
|
|
|
|
posZ = MathHelper.floor_double(player.posZ);
|
|
|
|
|
player.motionX = 0;
|
|
|
|
|
player.motionZ = 0;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canInteractWith(EntityPlayer player) {
|
|
|
|
|
return !player.isDead && posX == MathHelper.floor_double(player.posX) && posZ == MathHelper.floor_double(player.posZ);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 21:44:30 -05:00
|
|
|
public static IContainer getOrCreateIContainer(ContainerNpcInterface container) {
|
|
|
|
|
if (container.scriptContainer != null) {
|
|
|
|
|
return container.scriptContainer;
|
|
|
|
|
} else {
|
|
|
|
|
return container.scriptContainer = new ScriptContainer(container);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|