use of net.minecraft.world.dimension.DimensionType 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