-
Posts
43 -
Joined
-
Last visited
Everything posted by Taskkill
-
First, please excuse my spelling errors. I need to get the list of the entities that can summon by the commands. I've tried EntityList#getEntityNameList and EntityList#getClass , but as I'm using this, game crashed because of the Entity that spawned. Please tell me how to do, thanks. package task.heartstone.register; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Set; import org.apache.logging.log4j.LogManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.passive.EntityPig; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class EntityUtil { public static final List<Class<? extends Entity>> list = new ArrayList<Class<? extends Entity>>(); public static void load() { Set<ResourceLocation> namelist = EntityList.getEntityNameList(); for(ResourceLocation name : namelist) { Class<? extends Entity> clazz = EntityList.getClass(name); if(clazz != null) { list.add(clazz); } } for(Class clazz : list) { LogManager.getLogger("EntityUtil").info(clazz.getName()); } } public static Entity getRandEntity(World world) { Random rand = new Random(); int index = rand.nextInt(list.size()-1); return EntityList.newEntity(list.get(index), world); } }
-
Thank you very much!!!
-
Is that can change by anvil? I need the vanilla name...
-
I tried getUnlocalizedName() + ".name", but if the item has metadata like dye, it doesn't work. What can I do?
-
[1.12] How to get drop item of a destroyed block
Taskkill replied to Taskkill's topic in Modder Support
Thanks! -
How to get drop item of a destroyed block? (My English is not good at all. So...)
-
Code: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(!worldIn.isRemote) { ItemStack itemstack = playerIn.getHeldItem(handIn); NBTTagCompound nbt = itemstack.getTagCompound(); int blood = nbt.hasKey("blood") ? nbt.getInteger("blood") : 0; if(playerIn.isSneaking()) { blood += 2; playerIn.attackEntityFrom(BloodLose, 2.0f); } else { blood -= 5; playerIn.setHealth(playerIn.getHealth() + 5.0f); } nbt.setInteger("blood", blood); } return super.onItemRightClick(worldIn, playerIn, handIn); } Console: Caused by: java.lang.NullPointerException at TCr.Dark.items.tools.SwordDark.onItemRightClick(SwordDark.java:34) ~[SwordDark.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:234) ~[ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:384) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItem(NetHandlerPlayServer.java:794) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151] at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?] ... 5 more
-
Thanks, I find it.
-
How to register Enchantments, I just find GameRegistry.register(), but it can't be use as version 1.12
-
I know that is basic java, but I just know a little about Map, so... But thanks!
-
Thanks!
-
Thanks, but how can I turn this Map into int array.
-
Integer[] dimensions = DimensionManager.getStaticDimensionIDs();
-
It didn't crash, just throw this. [23:19:24] [Server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151] at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:796) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_151] Caused by: java.lang.NullPointerException at TCr.Dark.items.DimensionWand.onItemRightClick(DimensionWand.java:34) ~[DimensionWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:234) ~[ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:384) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItem(NetHandlerPlayServer.java:794) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151] at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?] ... 5 more
-
package TCr.Dark.items; import java.util.stream.Stream; import TCr.Dark.Dark; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.DimensionType; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; public class DimensionWand extends Item { public DimensionWand() { this.setUnlocalizedName("DimensionWand"); this.setRegistryName("dimension_wand"); this.setCreativeTab(Dark.tab); this.setMaxDamage(20); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(!worldIn.isRemote) { NBTTagCompound nbt = playerIn.getHeldItem(handIn).getTagCompound(); int[] dimensions = Stream.of(DimensionType.values()).flatMapToInt(t -> Stream.of(DimensionManager.getDimensions(t))).distinct(); int max = dimensions.length; if(playerIn.isSneaking()) { playerIn.changeDimension(nbt.getInteger("dimension")); } else { int k = 0; k++; if(k > max) k = 0; nbt.setInteger("dimension", dimensions[k]); playerIn.sendMessage(new TextComponentString(I18n.format("dimensionWand.dim")+dimensions[k])); } } return super.onItemRightClick(worldIn, playerIn, handIn); } }
-
I wanna get a list of dimensions. So I tried DimensionManager.getStaticDimensionIDs(), but it doesn't work. It throws "java.lang.NullPointerException" And I tried another way that from diesieben07,but it still can't work and my eclipse tell me that "Type mismatch: cannot convert from IntStream to int[]".
-
How to change item name when it craft?