use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class RenderEventHandler method onFOVChange.
@SubscribeEvent
public static void onFOVChange(FOVUpdateEvent event) {
PlayerEntity player = event.getEntity();
if (player.isPotionActive(NetherExEffects.FROZEN.get())) {
float fov = 1.0F;
if (player.abilities.isFlying) {
fov *= 1.1F;
}
if (player.isHandActive() && player.getActiveItemStack().getItem() instanceof BowItem) {
float useCount = (float) player.getItemInUseMaxCount() / 20.0F;
if (useCount > 1.0F) {
useCount = 1.0F;
} else {
useCount = useCount * useCount;
}
fov *= 1.0F - useCount * 0.15F;
}
event.setNewfov(fov);
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerTick.
@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
TickEvent.Phase phase = event.phase;
World world = event.player.getEntityWorld();
PlayerEntity player = event.player;
if (phase == TickEvent.Phase.END) {
if (!world.isRemote) {
IInventory inventory = player.inventory;
int mirrorCount = 0;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
mirrorCount++;
if (mirrorCount > 1) {
ItemEntity item = new ItemEntity(world, player.getPosX(), player.getPosY() + 0.5F, player.getPosZ(), stack);
item.setPickupDelay(50);
world.addEntity(item);
inventory.setInventorySlotContents(i, ItemStack.EMPTY);
break;
}
}
}
}
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerLeftClick.
@SubscribeEvent
public static void onPlayerLeftClick(PlayerInteractEvent.LeftClickBlock event) {
World world = event.getWorld();
Direction direction = event.getFace();
BlockPos pos = event.getPos();
PlayerEntity player = event.getPlayer();
if (direction != null) {
BlockPos offsetPos = pos.offset(direction);
Block offsetBlock = world.getBlockState(offsetPos).getBlock();
if (offsetBlock == NetherExBlocks.BLUE_FIRE.get()) {
world.playEvent(player, 1009, offsetPos, 0);
world.setBlockState(offsetPos, Blocks.AIR.getDefaultState());
event.setCanceled(true);
}
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerClone.
@SubscribeEvent
public static void onPlayerClone(PlayerEvent.Clone event) {
PlayerEntity oldPlayer = event.getOriginal();
PlayerEntity newPlayer = event.getPlayer();
IInventory oldInventory = oldPlayer.inventory;
IInventory newInventory = newPlayer.inventory;
if (event.isWasDeath()) {
ItemStack mirrorStack = ItemStack.EMPTY;
for (int i = 0; i < oldInventory.getSizeInventory(); i++) {
ItemStack stack = oldInventory.getStackInSlot(i);
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
NBTHelper.ensureTagExists(stack);
if (stack.getTag().contains("SpawnPoint") && (stack.getDamage() < (stack.getMaxDamage() - 1))) {
stack.damageItem(1, newPlayer, entity -> {
});
}
newInventory.setInventorySlotContents(i, stack);
mirrorStack = stack;
break;
}
}
if (!mirrorStack.isEmpty()) {
if (mirrorStack.getDamage() < mirrorStack.getMaxDamage() - 1) {
CompoundNBT compound = NBTHelper.ensureTagExists(mirrorStack);
if (compound.contains("SpawnDimension") && compound.contains("SpawnPoint")) {
DimensionType spawnDimension = DimensionType.byName(new ResourceLocation(compound.getString("SpawnDimension")));
BlockPos spawnPoint = NBTUtil.readBlockPos(compound.getCompound("SpawnPoint"));
if (spawnDimension != null) {
newPlayer.setSpawnDimenion(spawnDimension);
newPlayer.setSpawnPoint(spawnPoint, true, false, spawnDimension);
}
}
}
}
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project Overloaded by CJ-MC-Mods.
the class ItemRailGun method onMouseEvent.
@SubscribeEvent
public void onMouseEvent(InputEvent.MouseScrollEvent event) {
ClientPlayerEntity player = Minecraft.getInstance().player;
if (event.getScrollDelta() != 0 && player != null && player.isShiftKeyDown()) {
ItemStack stack = player.getMainHandItem();
if (player.isShiftKeyDown() && !stack.isEmpty() && stack.getItem() == this) {
int powerDelta = Long.signum(Math.round(event.getScrollDelta())) * OverloadedConfig.INSTANCE.railGun.stepEnergy;
if (InputMappings.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), ((ClientProxy) Overloaded.proxy).railGun100x.getKey().getValue())) {
powerDelta *= 100;
}
Overloaded.proxy.networkWrapper.sendToServer(new RailGunSettingsMessage(powerDelta));
event.setCanceled(true);
}
}
}
Aggregations