use of net.minecraft.util.EnumHand in project ProjectE by sinkillerj.
the class GuiHandler method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = !ITEM_IDS.contains(ID) ? world.getTileEntity(new BlockPos(x, y, z)) : null;
// if not a TE, x will hold which hand it came from. 1 for off, 0 otherwise
EnumHand hand = ITEM_IDS.contains(ID) ? (x == 1 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND) : null;
switch(ID) {
case Constants.ALCH_CHEST_GUI:
if (tile != null && tile instanceof AlchChestTile)
return new AlchChestContainer(player.inventory, (AlchChestTile) tile);
break;
case Constants.ALCH_BAG_GUI:
{
EnumDyeColor color = EnumDyeColor.byMetadata(player.getHeldItem(hand).getItemDamage());
IItemHandlerModifiable inventory = (IItemHandlerModifiable) player.getCapability(ProjectEAPI.ALCH_BAG_CAPABILITY, null).getBag(color);
return new AlchBagContainer(player.inventory, hand, inventory);
}
case Constants.CONDENSER_GUI:
if (tile != null && tile instanceof CondenserTile)
return new CondenserContainer(player.inventory, (CondenserTile) tile);
break;
case Constants.TRANSMUTE_STONE_GUI:
return new TransmutationContainer(player.inventory, new TransmutationInventory(player), null);
case Constants.RM_FURNACE_GUI:
if (tile != null && tile instanceof RMFurnaceTile)
return new RMFurnaceContainer(player.inventory, (RMFurnaceTile) tile);
break;
case Constants.DM_FURNACE_GUI:
if (tile != null && tile instanceof DMFurnaceTile)
return new DMFurnaceContainer(player.inventory, (DMFurnaceTile) tile);
break;
case Constants.COLLECTOR1_GUI:
if (tile != null && tile instanceof CollectorMK1Tile)
return new CollectorMK1Container(player.inventory, (CollectorMK1Tile) tile);
break;
case Constants.COLLECTOR2_GUI:
if (tile != null && tile instanceof CollectorMK2Tile)
return new CollectorMK2Container(player.inventory, (CollectorMK2Tile) tile);
break;
case Constants.COLLECTOR3_GUI:
if (tile != null && tile instanceof CollectorMK3Tile)
return new CollectorMK3Container(player.inventory, (CollectorMK3Tile) tile);
break;
case Constants.RELAY1_GUI:
if (tile != null && tile instanceof RelayMK1Tile)
return new RelayMK1Container(player.inventory, (RelayMK1Tile) tile);
break;
case Constants.RELAY2_GUI:
if (tile != null && tile instanceof RelayMK2Tile)
return new RelayMK2Container(player.inventory, (RelayMK2Tile) tile);
break;
case Constants.RELAY3_GUI:
if (tile != null && tile instanceof RelayMK3Tile)
return new RelayMK3Container(player.inventory, (RelayMK3Tile) tile);
break;
case Constants.MERCURIAL_GUI:
return new MercurialEyeContainer(player.inventory, new MercurialEyeInventory(player.getHeldItem(hand)));
case Constants.PHILOS_STONE_GUI:
return new PhilosStoneContainer(player.inventory);
case Constants.TRANSMUTATION_GUI:
return new TransmutationContainer(player.inventory, new TransmutationInventory(player), hand);
case Constants.ETERNAL_DENSITY_GUI:
return new EternalDensityContainer(player.inventory, new EternalDensityInventory(player.getHeldItem(hand), player));
case Constants.CONDENSER_MK2_GUI:
return new CondenserMK2Container(player.inventory, (CondenserMK2Tile) tile);
}
return null;
}
use of net.minecraft.util.EnumHand in project Zollern-Galaxy by alphawolf918.
the class ZGEvents method setFarmland.
/**
* Set the block at the passed position to farmland.
*
* @param event
* @param world
* @param pos
* @param farmland
*/
private void setFarmland(UseHoeEvent event, World world, BlockPos pos, Block farmland) {
world.setBlockState(pos, farmland.getDefaultState());
event.setResult(Result.ALLOW);
SoundEvent stepSound = SoundType.GROUND.getStepSound();
SoundCategory soundCategory = SoundCategory.BLOCKS;
float soundVolume = (SoundType.GROUND.getVolume() + 1.0F) / 2.0F;
float soundPitch = SoundType.GROUND.getPitch() * 0.8F;
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), stepSound, soundCategory, soundVolume, soundPitch);
for (EnumHand hand : CachedEnumZG.valuesHandCached()) {
event.getEntityPlayer().swingArm(hand);
}
}
use of net.minecraft.util.EnumHand in project ElementalSorcery by Yuzunyannn.
the class EventServer method onInteractWithEntity.
// 实体交互
@SubscribeEvent
public static void onInteractWithEntity(PlayerInteractEvent.EntityInteract event) {
EntityPlayer player = event.getEntityPlayer();
if (player.world.isRemote) {
if (PocketWatchClient.isActive())
event.setCanceled(true);
return;
}
Entity target = event.getTarget();
EnumHand hand = event.getHand();
if (hand == EnumHand.MAIN_HAND)
EntityFairyCube.addBehavior(player, BehaviorInteract.interact(target, hand));
Researcher.onInteractWithEntity(player, target, hand);
if (PocketWatch.isActive(event.getWorld()))
event.setCanceled(true);
}
use of net.minecraft.util.EnumHand in project ElementalSorcery by Yuzunyannn.
the class ItemRabidLeather method onUpdate.
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (worldIn.isRemote)
return;
EnumHand hand = ItemVortex.inEntityHand(entityIn, stack, itemSlot, isSelected);
if (hand == null)
return;
if (entityIn.ticksExisted % 100 == 0) {
((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(MobEffects.SPEED, 120, 1));
((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(MobEffects.HASTE, 120, 1));
}
}
use of net.minecraft.util.EnumHand in project ElementalSorcery by Yuzunyannn.
the class ItemVortex method onUpdate.
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
EnumHand hand = ItemVortex.inEntityHand(entityIn, stack, itemSlot, isSelected);
if (hand == null)
return;
if (entityIn instanceof EntityPlayer) {
if (((EntityPlayer) entityIn).isCreative())
return;
}
double f = 0.2;
entityIn.motionX += (Math.random() - 0.5) * f;
entityIn.motionY += (Math.random() - 0.5) * f;
entityIn.motionZ += (Math.random() - 0.5) * f;
}
Aggregations