Jump to content

Recommended Posts

Posted

As the subject suggests, I would like some advice on porting a mod to 1.7.2 and possibly beyond. The mod I plan to port is open Sourced, and went by the name of Rise of The Automatons, and stopped being Officially updated in 1.2.5 minecraft. I have ideas for it that could change it drastically, which is one reason for my efforts. I may just need a push in the right direction, or the source is really jumbled. All I know is the source code is quite incoherent for me atleast. Any help will be appreciated.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Since it dating back to 1.2.5 i recommend recoding it from scratch. so much have changed that your gonna more or less recode everything.

 

 

Naturalis - The easy way for nature.!

Esquire - A helping hand for your adventure.

Jimanju - The Random Disasters!

Posted

I thought that was what I had to do, I just have to hope that I can figure out some of the stuff the original modder added.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Usually 1.2.5 means you have client source and server source.

Updating would need merging the two, then use packets to send appropriate data.

I already worked on Rise of the Automatons but never finished. You can see the progress on my github (Zetgeist repo).

Posted

hmm.. welp, I tried to get the Duplex block to work, so far I have been able to replicate the 9 drop ratio. But I can't for the life of me get the old ability that occurs after it's broken to break all connecting blocks of itself and only drop 9. This is the code of it from 1.2.5 that I assume dealt with the ability, probably changed with updates:

 

 

 

public void onBlockRemoval(World world, int i, int j, int k) {

world.spawnParticle("reddust", i + 0.5F, j + 0.5F, k + 0.5F, 0, 0.2F, 0);

if (world.getBlockId(i + 1, j, k) == blockID) {

world.setBlock(i + 1, j, k, 0);

}

if (world.getBlockId(i - 1, j, k) == blockID) {

world.setBlock(i - 1, j, k, 0);

}

if (world.getBlockId(i, j, k - 1) == blockID) {

world.setBlock(i, j, k - 1, 0);

}

if (world.getBlockId(i, j, k + 1) == blockID) {

world.setBlock(i, j, k + 1, 0);

}

if (world.getBlockId(i, j - 1, k) == blockID) {

world.setBlock(i, j - 1, k, 0);

}

if (world.getBlockId(i, j + 1, k) == blockID) {

world.setBlock(i, j + 1, k, 0);

}

}

 

 

And this is what someone who ported it to 1.6.4 changed it to:

 

 

public void func_71898_d(World world, int i, int j, int k, int par5)

{

world.func_72869_a("reddust", i + 0.5F, j + 0.5F, k + 0.5F, 0.0D, 0.2000000029802322D, 0.0D);

if (world.func_72798_a(i + 1, j, k) == this.field_71990_ca) {

world.func_72832_d(i + 1, j, k, 0, 0, 3);

}

if (world.func_72798_a(i - 1, j, k) == this.field_71990_ca) {

world.func_72832_d(i - 1, j, k, 0, 0, 3);

}

if (world.func_72798_a(i, j, k - 1) == this.field_71990_ca) {

world.func_72832_d(i, j, k - 1, 0, 0, 3);

}

if (world.func_72798_a(i, j, k + 1) == this.field_71990_ca) {

world.func_72832_d(i, j, k + 1, 0, 0, 3);

}

if (world.func_72798_a(i, j - 1, k) == this.field_71990_ca) {

world.func_72832_d(i, j - 1, k, 0, 0, 3);

}

if (world.func_72798_a(i, j + 1, k) == this.field_71990_ca) {

world.func_72832_d(i, j + 1, k, 0, 0, 3);

}

}

 

 

 

also for future reference.. How would I get to setting up blocks with metadata?

any help is appreciated

 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

What version of forge are you using???

 

when updated to the latest Recommend you dont have all the func names.

and this should be enough to set it up

    public void onBlockDestroyedByPlayer(World world, int j, int k, int l, int par4)
    {
        if (world.getBlock(j, k, l) == this)
        {
            world.setBlockToAir(j, k, l);
        }
        
    }

Naturalis - The easy way for nature.!

Esquire - A helping hand for your adventure.

Jimanju - The Random Disasters!

Posted

would it be possible to utilize that in an if statement?

 

 

edit--

ok, seems that even with that code in the latest recommended version, it still seems that the block doesn't destroy other blocks next to it that are the same block. Other words, what I want it to be able to break other blocks that are the same as itself when they are touching, or do I just utilize similar code from old code

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

did you not see the if?

 

i made the first if you have.

Naturalis - The easy way for nature.!

Esquire - A helping hand for your adventure.

Jimanju - The Random Disasters!

Posted

No I mean if I want to make a single class for similar blocks, like a glass type, and I want to have this ability only happen for one of the types of glass based on name, what could I do? Also how could I have a given attribute from a method go to another method in a block class?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

To make it destroy block next to it you have to change the jkl to +1 and -1, like in the if statements you brought.

 

you can try other setblocks.

 

if i understand you right you mean you want it to only works on block with the same metadata?

 

and that you want other blocks to extend this class?

Naturalis - The easy way for nature.!

Esquire - A helping hand for your adventure.

Jimanju - The Random Disasters!

Posted

Well I was able to get it to work with this coding :P :

 

public class AM_BlockGlass extends Block{

 

 

String blockName;

public AM_BlockGlass(String name, float hardness, String blocktexture) {

super(Material.glass);

this.setBlockName(name);

this.setHardness(hardness);

this.setBlockTextureName(Strings.MODID + ":" + blocktexture);

this.setStepSound(Block.soundTypeGlass);

this.setCreativeTab(AM_CreativeTabs.tabBlock);

if(name == "Duplex"){

blockName = name;

}

}

 

public void onBlockDestroyedByPlayer(World world, int j, int k, int l, int par4)

    {

 

    if(blockName == "Duplex")

and following it with the method to run when it's destroyed, though it does seem to only break the blocks right next to it, and not every block of it that is touching

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Im not sure im following you when you say

though it does seem to only break the blocks right next to it, and not every block of it that is touching

[/Quote]

 

i mean if it only break 1 block instead of the 26 in a 3x3x3 you just have to add a setblockair for each of the location inside the if

Naturalis - The easy way for nature.!

Esquire - A helping hand for your adventure.

Jimanju - The Random Disasters!

Posted

Thank you, I thought that would be what I had to do... Also would I do something similar to that if I wanted a certain block to break and drop itself when hit by or touching water source/still, without changing it's material to circuits? And would it be possible to allow the placement of torches on the side of a block with the material set to glass? Also another question... I'm trying to make a block mineable by Iron Pickaxe and up, but for some reason the gold pickaxe won't mine it aswell, how could I get that to work. Also for future usage, how can I utilize the ore dictionary for my blocks and items, as well as how to use metadata for blocks?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

  • 3 weeks later...
Posted

Ok, now I have figured out how to utilize metadata to create subBlocks, aswell as multisided textures for blocks. Now I need a little help in a few things. For one I wouldn't mind a bit of an explanation on how to code a block that spreads like grass and why it does it. As well as how to make a specified block texture to rotate towards the player when placed, like a furnace. I mean I could look at the vanilla codes, but some of it doesn't make sense completely. Any help is appreciated

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Ok, I've gotten the hang of making a spreading block, and wanted to make it spread in a more controlled state, i.e only turn blocks surrounding it in a 3x3 area, and the following code does work, but I would like to know if there is a way I could simplify this, since I want it to turn certain blocks into other different blocks, may use subBlocks with metadata:

 

*vanilla blocks as placeholders

 

   if (world.getBlock(x + 1, y, z) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x + 1, y, z, Blocks.glass);
                    }
                    if (world.getBlock(x - 1, y, z) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x - 1, y, z, Blocks.glass);
                    }
                    
                    if (world.getBlock(x + 1, y, z + 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x + 1, y, z + 1, Blocks.glass);
                    }      
                    
                    if (world.getBlock(x - 1, y, z - 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x - 1, y, z - 1, Blocks.glass);
                    }   
                    
                    if (world.getBlock(x + 1, y, z - 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x + 1, y, z - 1, Blocks.glass);
                    }
                    
                    if (world.getBlock(x - 1, y, z + 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x - 1, y, z + 1, Blocks.glass);
                    }     
                    
                    if (world.getBlock(x, y, z + 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x, y, z + 1, Blocks.glass);
                    }
                    if (world.getBlock(x, y, z - 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
                    {
                        world.setBlock(x, y, z - 1, Blocks.glass);
                    }

 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Hint: You can use [ code ] tags inside [ spoiler ] tags, or you can paste as a gist for syntax highlight and line numbers :)

 

I am not sure why you call

getBlockLightValue

and

getBlockLightOpacity

with the same coordinates every time. Assuming you want to call it on the block you are spreading to, and assuming you only want one such conversion per random tick, this would be a way to do it more concisely:

 

for (int i = x-1; i <= x+1; ++i) {
    for (int j = z-1; j <= z+1; ++j) {
        if (world.getBlock(i, y, j) == Blocks.grass && world.getBlockLightValue(i, y, j) >= 4 && world.getBlockLightOpacity(i, y, j) <= 2) {
            world.setBlock(i, y, j, Blocks.glass);
        }
    }
}

 

Keep in mind that this converts horisontally exclusively.

Posted

Ok, I may have put it in the wrong place, because for some reason it doesn't seem to spread now. I put the new code in the

 for (int l = 0; l < 97; ++l)

method where I changed the default growth speed of '4' to 97 to see effects quicker than grass growth. can I know why it doesn't spread now?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Ok this is from the updateTick Method of my block class with the code suggested:

public void updateTick(World world, int x, int y, int z, Random random)
    {
        if (!world.isRemote)
        {
            if (world.getBlockLightValue(x, y + 1, z) >= 9)
            {
                for (int l = 0; l < 97; ++l)
                {
                    /*int i1 = x + random.nextInt(3) - 1;
                    int j1 = y + random.nextInt(5) - 3;
                    int k1 = z + random.nextInt(3) - 1;
                    Block block = world.getBlock(i1, j1 + 1, k1); */

                	for (int i = x-1; i <= x+1; ++i) {
                	    for (int j = z-1; j <= z+1; ++j) {
                	        if (world.getBlock(i, y, j) == Blocks.grass && world.getBlockLightValue(i, y, j) >= 4 && world.getBlockLightOpacity(i, y, j) <= 2) {
                	            world.setBlock(i, y, j, Blocks.glass);
                	        }
                	    }
                	}
                }
            }
        }
    }

 

I also plan to use similar working code for a block to be able to "destroy" not mine blocks nearby if those blocks are the same within a 3x3x3 cube area, which would reside within a onBlockDestroyedByPlayer method.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Your block won't tick more often just because you run a loop 97 times. Besides, since you're not using

l

, all 97 iterations are identical, with no change to the state of the world between them - the iterations are moot.

 

Also, you are comparing the light value of the block above your block.

Posted

hmm, so how do I fix it? because I just modified the code that worked from the BlockGrass class, and it did seem to speed up when I changed the basic code from 4 to 97?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Basically I want it to be able to spread to certain blocks that are next to each of it's sides except for direct top and direct bottom of the block that does this. And possibly turn other blocks into a block of a different metadata. Like block B turns into Block A.0, block C turns into block A.1, etc 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

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

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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