use of net.minecraftforge.eventbus.api.SubscribeEvent in project Geolosys by oitsjustjose.
the class BlockColorInit method registerBlockColors.
@SubscribeEvent
public static void registerBlockColors(ColorHandlerEvent.Block evt) {
BlockColors blockColors = evt.getBlockColors();
blockColors.register((unknown, lightReader, pos, unknown2) -> lightReader != null && pos != null ? BiomeColors.getGrassColor(lightReader, pos) : GrassColors.get(0.5D, 1.0D), ModBlocks.getInstance().peat);
blockColors.register((unknown, lightReader, pos, unknown2) -> lightReader != null && pos != null ? BiomeColors.getGrassColor(lightReader, pos) : GrassColors.get(0.5D, 1.0D), ModBlocks.getInstance().rhododendron);
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project Geolosys by oitsjustjose.
the class BlockColorInit method registerItemColors.
@SubscribeEvent
public static void registerItemColors(ColorHandlerEvent.Item evt) {
final BlockColors blockColors = evt.getBlockColors();
final ItemColors itemColors = evt.getItemColors();
// Use the Block's colour handler for an ItemBlock
IItemColor itemBlockColourHandler = (stack, tintIndex) -> {
BlockState state = ((BlockItem) stack.getItem()).getBlock().getDefaultState();
return blockColors.getColor(state, null, null, tintIndex);
};
if (itemBlockColourHandler != null) {
itemColors.register(itemBlockColourHandler, ModBlocks.getInstance().peat);
itemColors.register(itemBlockColourHandler, ModBlocks.getInstance().rhododendron);
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerDrop.
@SubscribeEvent
public static void onPlayerDrop(LivingDropsEvent event) {
LivingEntity livingEntity = event.getEntityLiving();
Iterator<ItemEntity> iter = event.getDrops().iterator();
if (livingEntity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) livingEntity;
while (iter.hasNext()) {
ItemEntity entityItem = iter.next();
ItemStack stack = entityItem.getItem();
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
player.setItemStackToSlot(EquipmentSlotType.MAINHAND, stack);
iter.remove();
break;
}
}
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerRespawn.
@SubscribeEvent
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
World world = event.getPlayer().getEntityWorld();
PlayerEntity player = event.getPlayer();
PlayerInventory playerInventory = player.inventory;
if (!world.isRemote) {
ItemStack mirrorStack = ItemStack.EMPTY;
for (int i = 0; i < playerInventory.getSizeInventory(); i++) {
ItemStack stack = playerInventory.getStackInSlot(i);
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
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")));
if (spawnDimension != null && player.dimension != spawnDimension) {
MinecraftServer server = world.getServer();
if (server != null) {
BlockPos spawnPoint = NBTUtil.readBlockPos(compound.getCompound("SpawnPoint"));
((ServerPlayerEntity) player).teleport(server.getWorld(spawnDimension), spawnPoint.getX() + 0.5D, spawnPoint.getY(), spawnPoint.getZ() + 0.5D, player.rotationYaw, player.rotationPitch);
}
}
}
}
}
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project NetherEx by LogicTechCorp.
the class PlayerHandler method onItemCrafted.
@SubscribeEvent
public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
PlayerEntity player = event.getPlayer();
ItemStack stack = event.getCrafting();
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
if (stack.getDamage() < stack.getMaxDamage()) {
CompoundNBT compound = NBTHelper.ensureTagExists(stack);
compound.putBoolean("RemovedSpawn", false);
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) {
player.setSpawnDimenion(spawnDimension);
player.setSpawnPoint(spawnPoint, true, false, spawnDimension);
}
}
}
}
}
Aggregations