Jump to content

Recommended Posts

Posted (edited)
6 minutes ago, Animefan8888 said:

It exists in the Block class. You need to override it in your Block class I believe is called MPlant.

there's only two things that don't have an @Override already:

 

    public MPlant(Properties builder)
    {
        super(builder);
        this.setDefaultState(this.stateContainer.getBaseState().with(this.getAgeProperty(), Integer.valueOf(0)));
    }

_____________________________________________________________________________________________________________

and this one: 

 

 @OnlyIn(Dist.CLIENT)
    public ItemStack getItem(IBlockReader worldIn, BlockPos pos, BlockState state)
    {
       return new ItemStack(this.getSeedsItem());
    }

 

 

 

I assume its the first one?

 

 

edit: nevermind. its not the first one

Edited by Guest
  • Replies 96
  • Created
  • Last Reply

Top Posters In This Topic

Posted
Just now, DrMDGG said:

I assume its the first one?

No. You don't know Java do you? First the @Override annotation doesn't actually do anything. It just lets you know that you are overriding a method from a parent class(hurray for inheritance). Secondly the method is a new one you have to add to your class. If it doesn't exist with the name fillStateContainer then it's likely that you are using an outdated version of forge. I'm only on 28.1.19

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
38 minutes ago, Animefan8888 said:

No. You don't know Java do you? First the @Override annotation doesn't actually do anything. It just lets you know that you are overriding a method from a parent class(hurray for inheritance). Secondly the method is a new one you have to add to your class. If it doesn't exist with the name fillStateContainer then it's likely that you are using an outdated version of forge. I'm only on 28.1.19

yeah. I updated forge, and low and behold, it came up.

https://github.com/drmdgg/marijuanacraft/blob/master/src/main/java/drmdgg/marijuanacraft/init/blocks/plants/MPlant.java

 

so I added that and changed getAge to getCropAge

 

what did I do wrong?

Posted
21 minutes ago, Animefan8888 said:

I assume the same "error" is happening?

yeah. block breaks properly. no bonemeal. no growing. no texture

Posted
On 10/13/2019 at 9:11 AM, Animefan8888 said:

I assume the same "error" is happening?

is this error happening due to the lack of references to my plant seed not being in my seed class and the mplant class not referencing my mplant?

Posted

You only need two references:

 

  1. The block instance is passed to the seed item's constructor
  2. The item instance is returned in the block's getSeedsItem method via a ModItems (ItemList) reference.

That's it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
4 minutes ago, Draco18s said:

You only need two references:

 

  1. The block instance is passed to the seed item's constructor
  2. The item instance is returned in the block's getSeedsItem method via a ModItems (ItemList) reference.

That's it.

okay, well it has all that...so what's the problem. at one point I get this in my runclient:

[16:51:03] [Server-Worker-2/WARN] [minecraft/ModelBakery]: Exception loading blockstate definition: 'marijuanacraft:blockstates/mplant.json' in resourcepack: 'main' for variant: 'age=5': Unknown blockstate property: 'age'

 

 

Posted
56 minutes ago, DrMDGG said:

Exception loading blockstate definition: 'marijuanacraft:blockstates/mplant.json' in resourcepack: 'main' for variant: 'age=5': Unknown blockstate property: 'age'

For some reason it isnt recognizing that your block has an age property and when it is reading the blockstate json its seeing this and going "HUH?!?!"

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
3 minutes ago, Animefan8888 said:

For some reason it isnt recognizing that your block has an age property and when it is reading the blockstate json its seeing this and going "HUH?!?!"

any guesses on how to fix that? I've checked that json file and the others a billion times against the carrots and the wheat (which are obviously the same)

Posted
4 minutes ago, DrMDGG said:

any guesses on how to fix that? I've checked that json file and the others a billion times against the carrots and the wheat (which are obviously the same)

The problem doesnt lie within the json. The problem lies within the code. Specifically why your block isnt getting the age property. Have you looked at the f3 screen while looking at your block to see if it has the age property on the right hand side of the screen?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
10 minutes ago, Animefan8888 said:

The problem doesnt lie within the json. The problem lies within the code. Specifically why your block isnt getting the age property. Have you looked at the f3 screen while looking at your block to see if it has the age property on the right hand side of the screen?

it definitely does not

mcraftf3.png

Posted
6 minutes ago, DrMDGG said:

it definitely does not

Double check that in your fillStateContainer method you add your age property to the Builder parameter.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
15 minutes ago, Animefan8888 said:

Double check that in your fillStateContainer method you add your age property to the Builder parameter.

like this?

 

    @Override
    protected void fillStateContainer(Builder<Block, BlockState> builder) {
        
        builder.add(CROP_AGE);
        
        

Posted
2 hours ago, Animefan8888 said:

Double check that in your fillStateContainer method you add your age property to the Builder parameter.

okay, so I triple...or maybe quadruple checked the cropsblock class and the code there is "builder.add(AGE);"

but if i'm extending CropsBlock then shouldn't all the age stuff be automatically added and unnecessary for me to add?

Posted
1 minute ago, DrMDGG said:

but if i'm extending CropsBlock then shouldn't all the age stuff be automatically added and unnecessary for me to add?

Exactly make sure your fillStateContainer is being called though. I'm curious if something is broken.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
6 minutes ago, Animefan8888 said:

Exactly make sure your fillStateContainer is being called though. I'm curious if something is broken.

please...be my guest...you'd see it faster than me, i'm sure:

 

https://pastebin.com/Ji2QtwnG

Posted
12 hours ago, Animefan8888 said:

Exactly make sure your fillStateContainer is being called though. I'm curious if something is broken.

i also noticed that it will spawn on any block, not just farmland

Posted

I suspect that the block being used by your seed item is not actually your crop block. But with the code you have, I'm not sure why that is.

My guess is that the item you're holding is not the one that we've been talking about, but another item entirely.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 hour ago, Draco18s said:

I suspect that the block being used by your seed item is not actually your crop block. But with the code you have, I'm not sure why that is.

My guess is that the item you're holding is not the one that we've been talking about, but another item entirely.

I've gone through all my code. i must have missed something. 

 

you've seen my code in full. what item or block could possibly be doing this?

Posted
58 minutes ago, DrMDGG said:

you've seen my code in full. what item or block could possibly be doing this?

*Shrug*

From my point of view, you created a bunch of stuff all at once (maybe copy-pasted from an old version?) without checking any of it to make sure it worked before going for more.

 

Always work on one block or item or system at a time, make sure its working 100%* before moving on to another.

 

*Sure, there are things that interleave sometimes, such as a crop and its seed, those can be worked on as a single operational group. And sometimes you need to break a thing down into smaller pieces and work on them and they won't be 100% until the larger structure is done, but you can handle that with placeholders and TODOs, but there you know what part isn't complete when you test it (for example, my ore system relies heavily on Custom Ore Gen and several ore generation events that don't exist, but that doesn't mean I can't make the blocks, items, loot tables, recipes, and enchantments, I just know I can't test the ore gen and prospecting systems until those events exist).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
9 minutes ago, Draco18s said:

*Shrug*

From my point of view, you created a bunch of stuff all at once (maybe copy-pasted from an old version?) without checking any of it to make sure it worked before going for more.

 

Always work on one block or item or system at a time, make sure its working 100%* before moving on to another.

 

*Sure, there are things that interleave sometimes, such as a crop and its seed, those can be worked on as a single operational group. And sometimes you need to break a thing down into smaller pieces and work on them and they won't be 100% until the larger structure is done, but you can handle that with placeholders and TODOs, but there you know what part isn't complete when you test it (for example, my ore system relies heavily on Custom Ore Gen and several ore generation events that don't exist, but that doesn't mean I can't make the blocks, items, loot tables, recipes, and enchantments, I just know I can't test the ore gen and prospecting systems until those events exist). 

the original mod I made was for 1.8.9 so I couldn't copy anything.
but now everything is working order except for these damn crops thanks to you guys. I guess I'll just have to figure this out on my own if you can't help me further. thanks for the help. you'll be in my credits lol

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.