
ptolemy2002
Members-
Posts
27 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
ptolemy2002's Achievements

Tree Puncher (2/8)
0
Reputation
-
Thank you. My mod is working now.
-
Which event should I be using to accomplish this? Currently I am trying to subscribe to the TagsUpdatedEvent, but it doesn't appear to be called at all. @Mod.EventBusSubscriber(bus=Bus.FORGE) public static class GenericEvents { @SubscribeEvent public static void onTagsUpdated(TagsUpdatedEvent event) { ... } }
-
I'm trying to develop a simple mod that will export certain properties of every registered item to an external file. Most of my properties are working, but I'm having trouble trying to implement the burnTime property. First, I tried using item.getBurnTime(new ItemStack(item, 1)) and found that method was repeatedly returning "-1" because the value was to be determined by the vanilla Minecraft Logic. I then did some research and found that I could use this: ForgeHooks.getBurnTime(new ItemStack(item, 1)) I found that this was continuously returning "0" instead of my desired value, presumably because the map "VANILLA_BURNS" has no entry for the item. Finally, I tried using the deprecated FurnaceTileEntity.getBurnTimes().get(item) where I got the error java.lang.IllegalStateException: Tag minecraft:non_flammable_wood used before it was bound Stacktrace: at net.minecraft.tags.TagRegistry$NamedTag.getTag(TagRegistry.java:131) ~[forge-1.16.4-35.0.18_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.tags.TagRegistry$NamedTag.contains(TagRegistry.java:142) ~[forge-1.16.4-35.0.18_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.tileentity.AbstractFurnaceTileEntity.isNonFlammable(AbstractFurnaceTileEntity.java:161) ~[forge-1.16.4-35.0.18_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraft.tileentity.AbstractFurnaceTileEntity.addItemBurnTime(AbstractFurnaceTileEntity.java:175) ~[forge-1.16.4-35.0.18_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraft.tileentity.AbstractFurnaceTileEntity.getBurnTimes(AbstractFurnaceTileEntity.java:97) ~[forge-1.16.4-35.0.18_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at com.example.examplemod.ExampleMod.setup(ExampleMod.java:104) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) ~[eventbus-3.0.5-service.jar:?] {} at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239) ~[eventbus-3.0.5-service.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.5-service.jar:?] {} at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:120) ~[forge:?] {re:classloading} at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:121) ~[forge:?] {re:classloading} at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1800) ~[?:?] {} at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1792) ~[?:?] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[?:?] {} at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016) ~[?:?] {} at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665) ~[?:?] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598) ~[?:?] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) ~[?:?] {} Which seems to indicate that the burn times cannot be generated yet. I was generating my file during the "FMLCommonSetupEvent" event. How can I successfully retrieve the correct value for burnTime?
-
I believe that I fully understand this concept now and will try to adapt my code from other blocks. Thanks!
-
Thank you for clearing this up for me. So, if I replace my fields with properties and replace the position with a new block state whenever I want to update it, my code will work?
-
I see what you mean. I have changed the variables to be private, which I believe should fix that problem.
-
The field isn't static. I was referring to the instance of EnumFacing as the static value. It is being assigned to a field that is public. Therefore, each block should be able to edit these variables individually.
-
The code setting the default state is actually part of my constructor. The direction variable is a static value stored into a public variable. Here's my whole class: package mymod.blocks; import java.sql.ResultSet; import java.util.List; import java.util.Random; import org.lwjgl.input.Keyboard; import library.blocks.LibBlockOre; import library.util.Actions; import mymod.Main; import mymod.MyActions; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; public class MyBlock1 extends LibBlockOre { public double range = 3; public int height = 2; public EnumFacing direction; public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public MyBlock1(String registryName, String harvestTool, int harvestLevel, EnumFacing facing) { super(registryName, harvestTool, harvestLevel); this.setCreativeTab(Main.my_creative_tab_1); this.setHardness(10.0F); this.setLightLevel(0.75F); this.setResistance(10000.0F); this.direction = facing; this.setDefaultState(blockState.getBaseState().withProperty(FACING, this.direction)); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (playerIn.isCreative()) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { this.range ++; Actions.chatAtPlayer(playerIn, TextFormatting.GOLD + "Range: " + TextFormatting.RESET + this.range); } else if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { this.height ++; Actions.chatAtPlayer(playerIn, TextFormatting.GOLD + "Height: " + TextFormatting.RESET + this.height); } else if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { this.range --; Actions.chatAtPlayer(playerIn, TextFormatting.GOLD + "Range: " + TextFormatting.RESET + this.range); } else if (Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) { this.height --; Actions.chatAtPlayer(playerIn, TextFormatting.GOLD + "Height: " + TextFormatting.RESET + this.height); } else { Actions.chatAtPlayer(playerIn, TextFormatting.GOLD + "Range: " + TextFormatting.RESET + this.range); Actions.chatAtPlayer(playerIn, TextFormatting.GOLD + "Height: " + TextFormatting.RESET + this.height); } } return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { state = state.withProperty(FACING, this.direction); if (worldIn.isRemote) { for (Entity i : MyActions.getEntities(worldIn)) { if (i.getPosition().getY() >= pos.getY() + this.height && MyActions.distanceTo(pos.getX(), pos.getY(), pos.getZ(), i.getPosition().getX(), i.getPosition().getY(), i.getPosition().getZ()) <= this.range) { double speed = MyActions.getPersistentNbtData(i).getDouble("Tower Speed"); boolean isTower = MyActions.getPersistentNbtData(i).getBoolean("Is Tower?"); if (speed > 0 && isTower) { //These directions are incompatible with the directional methods used. if (!(this.direction == EnumFacing.UP || this.direction == EnumFacing.DOWN)) { MyActions.setEntityRotation(i, MyActions.stringFormEnumFacing(this.direction)); } //Set motion to control where the entity goes. switch (state.getValue(FACING)) { case NORTH: i.setVelocity(0, 0, speed * -1); break; case SOUTH: i.setVelocity(0, 0, speed * 1); break; case EAST: i.setVelocity(speed * 1, 0, 0); break; case WEST: i.setVelocity(speed * 1, 0, 0); break; case UP: i.setVelocity(0, speed * 1, 0); break; case DOWN: i.setVelocity(0, speed * -1, 0); break; } } } } } super.updateTick(worldIn, pos, state, rand); } } My code uses a lot of methods coming from custom classes. Tell me if you would like the code for those classes.
-
I have a block that is like a conveyor belt. I want the block to always point in the direction that it will push the entity. I am aware that the block direction is defined by the block state, so I set the default block state using this code: public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); this.setDefaultState(blockState.getBaseState().withProperty(FACING, this.direction)); And attempted to update the block state with this code: @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { state = state.withProperty(FACING, this.direction); } However, when the block is placed into the world, the block does not face the correct direction. What should I do?
-
You can make the player move by editing x y and z motion variables or using the addVelocity method inside of the player class. I am not sure about digging, but I know you can make the player swing it's arm.
-
How to spawn Entities as part of a generated structure
ptolemy2002 replied to ptolemy2002's topic in Modder Support
I thought that the chunks would stay loaded after I spawned the entities, but I see that I have thought wrong. If the original Minecraft structures use it, then I should be fine with this. -
I want to spawn an entity inside my generated structure, but they keep despawning when the structure gets too far away. In order to avoid this, I am forcing the mobs I find to persist in the world, But this uses a lot of memory, as all of those chunks with the structure get loaded into memory until the mob dies. I am aware that structures such as the end city and woodland mansion do not seem to have this problem. How do I do this?
-
I need to clone an entity when I spawn it so that I can have multiple of the same entity in the world at once. I use this code: //If we are on the client side if (!worldIn.isRemote) { Entity entity = ((Entity) thingToPlace); Entity entity2 = (Entity) EntityList.createEntityFromNBT(entity.getEntityData(), worldIn); //Set the EntitY's location entity2.setPosition(pos.getX(), pos.getY(), pos.getZ()); //Spawn the entity worldIn.spawnEntity(entity2); } I got a null pointer exception on that code, and I figured out it was because the value "id" was not set in the nbt I passed, so Minecraft skipped the entity and returned null. I added this code: entity.getEntityData().setString("id", entity.getName()); and that seemed to work, but I am not sure if this is what I am supposed to do and if this will cause problems. What is the proper way to solve this problem?
-
[1.12.2] How to make the player sleep
ptolemy2002 replied to That_Martin_Guy's topic in Modder Support
There is a small chance that you would be able to copy the method to your own class and change it to edit the player externally.