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

than00ber1

Members
  • Posts

    30
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by than00ber1

  1. Mixins? https://github.com/SpongePowered/Mixin/wiki/Introduction-to-Mixins---Understanding-Mixin-Architecture#2-through-the-looking-glass
  2. 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.
  3. 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"?
  4. 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.
  5. Noted. I am trying to fetch Fence blocks and add an overlay to it. By you mean ICustomModelLoader?
  6. 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?
  7. 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...
  8. 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
  9. 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.
  10. 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?
  11. 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?
  12. 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?
  13. 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.
  14. I was able to solve the issue by rewriting all classes (must have gotten a class extending the wrong thing I think) but why shouldn't I use @OnlyIn on the renderers? Isn't it just client-side? Edit: Should I remove all @OnlyIn?
  15. I've been trying to register my cart entity to `RenderingRegistry`but I have been receiving errors I am having a hard time understanding. I register my entity renderer like this: public static void registerRenderers(final FMLClientSetupEvent event) { RenderingRegistry.registerEntityRenderingHandler(AllEntities.MINER_CART_ENTITY.get(), MinerModuleCartRenderer::new); } and this is my MinerModuleCartRenderer: @OnlyIn(Dist.CLIENT) public class MinerModuleCartRenderer<T extends AbstractMinecartEntity> extends EntityRenderer<T> { private static final ResourceLocation MINER_TEXTURE = new ResourceLocation(MODID + ":textures/entity/miner_cart_module.png"); private final EntityModel<T> modelCartModule = new MinerCartModuleModel<>(); public MinerModuleCartRenderer(EntityRendererManager renderManager) { super(renderManager); } public void render(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) { // [...] long code copied from MinecartRenderer directly } public ResourceLocation getEntityTexture(T entity) { return MINER_TEXTURE; } protected void renderBlockState(T entity, float partialTicks, BlockState state, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) { Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(state, matrixStack, buffer, packedLight, OverlayTexture.NO_OVERLAY); } } but I get this error: Bad return type in method reference: cannot convert com.than00ber.gameoflife.client.renderer.entity.MinerModuleCartRenderer<T> to net.minecraft.client.renderer.entity.EntityRenderer<? super ?> (I get the same error when trying to register Minecraft's `MinercartRenderer` like this) I've looked into Minecraft 's source code and noticed that it registers its entity renderers like this: public <T extends Entity> void register(EntityType<T> entityTypeIn, EntityRenderer<? super T> entityRendererIn) { this.renderers.put(entityTypeIn, entityRendererIn); } but Forge with `IRenderFactory`: public static <T extends Entity> void registerEntityRenderingHandler(EntityType<T> entityClass, IRenderFactory<? super T> renderFactory) { INSTANCE.entityRenderers.put(entityClass, renderFactory); } so I implemented `IRenderFactorty` in `MinerModuleCartRenderer` to see if it makes a difference but to no avail; the error stays the same. Any idea why that is and how can I solve this? Now I know this is more of Java error but I figured I'll get a better shot here since people have prior knowledge.
  16. Ah I managed to do this. The problem was really dumb, I didn't register the actual item itself. For any in the future that want to know how to it, this how I did it: Create the item: public class MinerCartItem extends MinecartItem { public MinerCartItem() { super(AbstractMinecartEntity.Type.RIDEABLE, (new Item.Properties()).maxStackSize(1).group(ItemGroup.FOOD)); } } and then register it the same way you would do for other registries: public static final RegistryObject<Item> MINER_ITEM = ITEMS.register("miner_item", MinerCartItem::new);
  17. Where would I call this? NetworkHooks.getEntitySpawningPacket(this) In the constructor of the minecart class?
  18. I am trying to register a simple minecart entity but it does not seem to appear in-game. No errors are thrown either. Here is my Minecart entity class: public class MinerCartEntity extends AbstractMinecartEntity { public MinerCartEntity(EntityType<?> type, World worldIn) { super(type, worldIn); } @Override public Type getMinecartType() { return Type.CHEST; } } Here is how I register it, public class AllEntities { public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, MODID); private static <T extends EntityType<?>> RegistryObject<EntityType<?>> register(String name, Supplier<T> entity) { System.out.println("REGISTERING MOD ENTITY: " + name); return ENTITIES.register(name, entity); } public static final RegistryObject<EntityType<?>> MINER_MINECART = register("miner_minecart", () -> EntityType.Builder.<AbstractMinecartEntity>create(MinerCartEntity::new, EntityClassification.MISC) .size(0.98F, 0.7F).trackingRange(8) .build(new ResourceLocation(MODID, "miner_minecart").toString())); } and in the main file simply: IEventBus fmlContext = FMLJavaModLoadingContext.get().getModEventBus(); AllBlocks.BLOCKS.register(fmlContext); AllTileEntities.TILE_ENTITIES.register(fmlContext); AllItems.ITEMS.register(fmlContext); AllEntities.ENTITIES.register(fmlContext); // <------ over here My first guess was to follow the same way to register entities as blocks or items while using the entity builder shown in Minecraft's source code. Any guess as to why it does not load in-game or not throwing errors? Is this even the right way?
  19. Yeah I am aware of that. Thanks for your respons, this helps a tone!
  20. I've recently fully finished my first mod for version 1.16.4 and was wondering what is the most efficient way of porting my mod to other game versions. I suppose you wouldn't create a new project repo to port from 1.16.4 to 1.16.5? Would I need to create a new repo to make the mod compatible with different but still relevant game versions like 1.12.2)? It's all a big mystery for me... PS: I am not sure if this is the correct thread to ask this question.
  21. Ok. I've tried this using ITextComponent instead: private static ITextComponent fromConfigKey(String key) { return ITextComponent.getTextComponentOrEmpty("config." + key); } This returns the key and not its translatation. I get the same result when calling getString or getUnformattedComponentText. Maybe this might help too. Heres how I try to register a config: public class Configs { ... public static ForgeConfigSpec.EnumValue<CarveType> CARVE_TYPE; public Configs(ForgeConfigSpec.Builder forgeConfigBuilder) { ConfigBuilder builder = new ConfigBuilder(forgeConfigBuilder); CARVE_TYPE = builder.defineEnum("carve_type", CarveType.CONNECTED, CarveType.values()); } private static class ConfigBuilder { private static ForgeConfigSpec.Builder BUILDER; private ConfigBuilder(ForgeConfigSpec.Builder builder) { BUILDER = builder; } ... public final <V extends Enum<V>> ForgeConfigSpec.EnumValue<V> defineEnum(String key, V defaultValue, V... enums) { ITextComponent note = noteFromConfigKey(key); return !note.getString().equals("") ? BUILDER.comment(fromConfigKey(key).getString(), note.getString()).defineEnum(key, defaultValue, enums) : BUILDER.comment(fromConfigKey(key).getString()).defineEnum(key, defaultValue, enums); } private static ITextComponent fromConfigKey(String key) { return ITextComponent.getTextComponentOrEmpty("config." + key); } private static ITextComponent noteFromConfigKey(String key) { return fromConfigKey(key + ".note"); } } public enum CarveType { CONNECTED, ALL } } This results in a config file like this: #config.carve_type #config.carve_type.note #Allowed Values: CONNECTED, ALL carve_type = "CONNECTED" and my en_us.json: { "config.carve_type": "Block carve type [...] " }
×
×
  • Create New...

Important Information

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