Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

than00ber1

Members
  • Posts

    29
  • Joined

  • Last visited

  • Days Won

    1

than00ber1 last won the day on October 4

than00ber1 had the most liked content!

Recent Profile Visitors

479 profile views

than00ber1's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. Alright. the FMLClientSetupEvent is not the corret event to listen to (at all). You will need to listen for the PlayerTickEvent event. public class PlayerTickHandler { @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { PlayerEntity player = event.player; if (player.getHealth() < 7) { player.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 60)); } } } And register it for Forge event bus inside your mod's construcor like this: MinecraftForge.EVENT_BUS.register(new PlayerTickHandler()); Note the @SubscribeEvent, this essentially tells forge that the methods is listening for an event.
  2. What do you not get? Are there any error logs you can show? What do you mean by "no forge practice on my forge file folder"?
  3. The mod causing this error is Extra Anvils. The error occurs because of how the mod gives a rainbow effect to text with some timing trickery. I believe this could be OS-related.
  4. Noted. I am trying to fetch Fence blocks and add an overlay to it. By you mean ICustomModelLoader?
  5. I am susbsribing to the ModelBakeEvent event but it seems to be skipped while the game loads. Here's how I subscribe to the event: public class ModelBakeHandler { // @OnlyIn(Dist.CLIENT) @SubscribeEvent public void onModelBakeEvent(ModelBakeEvent event) { System.out.println("_______________"); } } and register the event in my main class: MinecraftForge.EVENT_BUS.register(new ModelBakeHandler()); This is the event logs when the event gets triggered: [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Firing event for modid siltblocks : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Fired event for modid siltblocks : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Firing event for modid forge : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Fired event for modid forge : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b My "_______________" is not logged here (or ever). Any ideas why? Edit: Should I ever the "OnlyIn" decorator as a modder?
  6. Ok, found the issue. Within ModelBuilder, there are a few different method signatures for texture. Of which: public T texture(String key, String texture) : T and public T texture(String key, ResourceLocation texture) : T Method 1 uses <key> as the JSON key and <texture> as the asset path while in Method 2 <key> as the asset path and <texture> as the JSON key. Since I used the first method before and it my code worked, I assumed it was the same for the second method. Their paramaters are effectively swapped and this confused the hell out of me. In hindsight, I should read the comments more...
  7. I am trying to generate my block models with Data Generators which I incounter this error: Invalid ResourceLocation block/minecraft:sand It's easy to spot why this error occurs ("block/minecraft:sand", ':' triggers the error) but I don't understand where this error could come from by looking at my code. Since I have a few variants of the same block, I've replicated Minecraft's way by defining a template JSON for my variant and simply have my block use it as a parent and add a texture. Heres what I have: private void generateSiltBlockFenceGateFromTemplate(SiltFenceGateBlock gate) { String texture = Objects.requireNonNull(gate.getParentBlock().getRegistryName()).toString(); getVariantBuilder(gate).forAllStatesExcept(state -> { String base = "silt_fence_gate" + (state.get(OPEN) ? "_open_" : "_close_") + state.get(AbstractSiltBarrierBlock.LAYER); if (state.get(IN_WALL)) base = base + "_in_wall"; // <base> would look like "silt_fence_gate_close_1" ModelBuilder<?> model = models() .withExistingParent(texture + "_" + base, modLoc("block/template_" + base)) .texture("texture", mcLoc("block/" + texture)) // <--- stacktrace points here .element().end(); int rotation = (int) state.get(HORIZONTAL_FACING).getHorizontalAngle(); return ConfiguredModel.builder().modelFile(model).uvLock(true).rotationY(rotation).build(); }, WATERLOGGED ); } I've also tried to feed it a texture as a string directly but to no avail: .texture("texture", "block/" + texture) // <--- stacktrace points here What I expect is sand_silt_fence_gate_close_1.json: { "parent": "siltsand:block/template_silt_fence_gate_close_1" "textures": { "texture": "sand" } } Here's my template JSON: template_silt_fence_gate_close_1.json: { "parent": "block/block", "textures": { "particle": "#texture" }, "elements": [ { "from": [ 14, 0, 7 ], "to": [ 16, 1, 9 ], "faces": { "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "up": { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" } } }, { "from": [ 0, 0, 7 ], "to": [ 2, 1, 9 ], "faces": { "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "up": { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" } } }, { "from": [ 2, -1, 7 ], "to": [ 14, 0, 9 ], "faces": { "up": { "uv": [ 0, 0, 12, 2 ], "texture": "#texture" }, "north": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" } } }, { "from": [ 10, -7, 7 ], "to": [ 14, -6, 9 ], "faces": { "up": { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" }, "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" } } }, { "from": [ 2, -7, 7 ], "to": [ 6, -6, 9 ], "faces": { "up": { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" }, "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" } } } ] } I have read that maybe this might be caused by invalid JSON but that has been checked too. Any idea why this happens? PS: I am new to Data Gens so it is very likely that I using the builder wrong. PPS: Posted my issue in the wrong topic section
  8. I am trying to generate my block models with Data Generators which I incounter this error. It's easy to spot why this error occurs ("block/minecraft:sand", ':' triggers the error) but I don't understand where this error could come from by looking at my code. Since I have a few variants of the same block, I've replicated Minecraft's way by defining a template JSON for my variant and simply have my block use it as a parent and add a texture. Heres what I have: private void generateSiltBlockFenceGateFromTemplate(SiltFenceGateBlock gate) { String texture = Objects.requireNonNull(gate.getParentBlock().getRegistryName()).toString(); getVariantBuilder(gate).forAllStatesExcept(state -> { String base = "silt_fence_gate" + (state.get(OPEN) ? "_open_" : "_close_") + state.get(AbstractSiltBarrierBlock.LAYER); if (state.get(IN_WALL)) base = base + "_in_wall"; // <base> would look like "silt_fence_gate_close_1" ModelBuilder<?> model = models() .withExistingParent(texture + "_" + base, modLoc("block/template_" + base)) .texture("texture", mcLoc("block/" + texture)) // <--- stacktrace points here .element().end(); int rotation = (int) state.get(HORIZONTAL_FACING).getHorizontalAngle(); return ConfiguredModel.builder().modelFile(model).uvLock(true).rotationY(rotation).build(); }, WATERLOGGED ); } I've also tried to feed it a texture as a string directly but to no avail: .texture("texture", "block/" + texture) // <--- stacktrace points here What I expect is sand_silt_fence_gate_close_1.json: { "parent": "siltsand:block/template_silt_fence_gate_close_1" "textures": { "texture": "sand" } } Here's my template JSON: template_silt_fence_gate_close_1.json: { "parent": "block/block", "textures": { "particle": "#texture" }, "elements": [ { "from": [ 14, 0, 7 ], "to": [ 16, 1, 9 ], "faces": { "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "up": { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" } } }, { "from": [ 0, 0, 7 ], "to": [ 2, 1, 9 ], "faces": { "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "up": { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" } } }, { "from": [ 2, -1, 7 ], "to": [ 14, 0, 9 ], "faces": { "up": { "uv": [ 0, 0, 12, 2 ], "texture": "#texture" }, "north": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" } } }, { "from": [ 10, -7, 7 ], "to": [ 14, -6, 9 ], "faces": { "up": { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" }, "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" } } }, { "from": [ 2, -7, 7 ], "to": [ 6, -6, 9 ], "faces": { "up": { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" }, "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" }, "west": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }, "east": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" } } } ] } I have read that maybe this might be caused by invalid JSON but that has been checked too. Any idea why this happens? PS: I am new to Data Gens so it is very likely that I using the builder wrong.
  9. I am trying to listen for vanilla minecarts on every tick. In the past I would use `MinecartUpdateEvent` but in the newer version this seems to have been removed. Instead, I tried to listen for `EntityEvent#CanUpdate()` but this event is never called: https://github.com/MinecraftForge/MinecraftForge/issues/6394 Is there an alternative to listening for vanilla minecart on every tick?
  10. I am trying to set my entity's EntitySize fixed. I can set the entity's size with EntityType.Builder::size(float, float) which this calls EntitySize::flexible(float, float) but the builder does not seem to have a method with EntitySize::fixed(float, float) for setting fixed entity sizes. I figured I could make my own entity builder but that seems overkill just for this. Is there a better way to set an entity's size as fixed?
  11. Alright it works now, heres what I did to make it work. On the entity's side I call open the container like this: @Override public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) { if (!player.world.isRemote()) { NetworkHooks.openGui((ServerPlayerEntity) player, this, b -> b.writeInt(this.getEntityId())); } return ActionResultType.SUCCESS; } @Override public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) { PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); buffer.writeInt(this.getEntityId()); return new ContainerModuleCartMiner(id, playerInventory, buffer); } Where I assign the entity's id to a buffer and in the container: public ContainerModuleCartMiner(int id, PlayerInventory playerInventory, PacketBuffer buffer) { super(ContainerRegistry.MINER_CART_CONTAINER.get(), id); Entity entity = playerInventory.player.world.getEntityByID(buffer.readInt()); if (entity instanceof EntityModuleCartMiner) System.out.println(playerInventory.player.world.isRemote()); // outputs both 'ture' & 'false', meaning both client and server managed to get the entity from the buffer int } Edit: Is it ever possible for the packetbuffer to be null?
  12. I am trying to pass down my cart entity instance down to my container. I've tried a few different things which worked but never with the correct constructor paramaters (with my entity class). Heres how register my container, public static final RegistryObject<ContainerType<ContainerModuleCartMiner>> MINER_CART_CONTAINER = CONTAINERS.register("miner_module_cart", () -> new ContainerType(ContainerModuleCartMiner::new)); and call it like this within my entity class: // Entity class implements `IInventory` and `INamedContainerProvider` // server side? @Override public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) { if (!player.world.isRemote()) NetworkHooks.openGui((ServerPlayerEntity) player, this); return ActionResultType.SUCCESS; } // client side? @Override public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) { return new ContainerModuleCartMiner(id, playerInventory, this); } And my container looks like this: // constr. 1 public ContainerModuleCartMiner(int id, PlayerInventory playerInventory) { this(id, playerInventory, new Inventory(0)); } // constr. 2 public ContainerModuleCartMiner(int id, PlayerInventory playerInventory, IInventory inventory) { super(ContainerRegistry.MINER_CART_CONTAINER.get(), id); if (inventory instanceof EntityModuleCartMiner) System.out.println(playerInventory.player.world.isRemote) // outputs: false, client only this.loadPlayerInventory(playerInventory, ScreenModuleCartMiner.SIZE_X, ScreenModuleCartMiner.SIZE_Y); } The first constructor gets called on the server side which subsequently calls the second constructor with an empty inventory, only on the client side does the second constructor get called (from my understanding). Checking whether `inventory` is an instance of my entity only works in the client and not on the server. Is there a way to call the same constructor on both the client/server side with params `int`, `PlayerInventory` and `Entity` instead of `IInventory`directly? Also, I've tried calling the constructor with `int`, `PlayerInventory` and `PacketBuffer` and pass int the Entity's id along and retreive it on the other end with `world.getEntityById(buffer.readInt())` but it always seem to be null.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.