Jump to content

Recommended Posts

Posted (edited)

I created a custom "machine" but it crash.

Spoiler

package de.toocrazy007.reddeathmod.blocks;

import java.util.ArrayList;

import de.toocrazy007.reddeathmod.Deathblocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import scala.reflect.internal.Trees.If;

public class DeathCrafter extends Block {

    

    public DeathCrafter() {
        super(Material.ROCK);
        this.setCreativeTab(CreativeTabs.REDSTONE);

    }
    
    @Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
            EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
  
        int X = pos.getX();
        int Y = pos.getY();
        int Z = pos.getZ();
        ArrayList<Block> craftingblocks = new ArrayList<Block>();
        ArrayList<BlockPos> craftingpos = new ArrayList<BlockPos>();
        BlockPos block1 = new BlockPos(X-1,Y,Z);
        BlockPos block2 = new BlockPos(X+1,Y,Z);
        BlockPos block3 = new BlockPos(X,Y,Z-1);
        BlockPos block4 = new BlockPos(X,Y,Z+1);
        BlockPos block5 = new BlockPos(X-1,Y,Z-1);
        BlockPos block6 = new BlockPos(X+1,Y,Z-1);
        BlockPos block7 = new BlockPos(X-1,Y,Z+1);
        BlockPos block8 = new BlockPos(X+1,Y,Z+1);
        craftingblocks.add(0, (Block) worldIn.getBlockState(block1));
        craftingblocks.add(1, (Block) worldIn.getBlockState(block2));
        craftingblocks.add(2, (Block) worldIn.getBlockState(block3));
        craftingblocks.add(3, (Block) worldIn.getBlockState(block4));
        craftingblocks.add(4, (Block) worldIn.getBlockState(block5));
        craftingblocks.add(5, (Block) worldIn.getBlockState(block6));
        craftingblocks.add(6, (Block) worldIn.getBlockState(block7));
        craftingblocks.add(7, (Block) worldIn.getBlockState(block8));
        craftingpos.add(0,(block1));
        craftingpos.add(1,(block2));
        craftingpos.add(2,(block3));
        craftingpos.add(3,(block4));
        craftingpos.add(4,(block5));
        craftingpos.add(5,(block6));
        craftingpos.add(6,(block7));
        craftingpos.add(7,(block8));
        
        checkRecipes(craftingblocks, craftingpos, worldIn, pos);
        
        return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
    }

    private void checkRecipes(ArrayList<Block> craftingblocks, ArrayList<BlockPos> craftingpos, World worldIn, BlockPos pos) {
        if(craftingblocks.size() != 3)
            return;
        BlockPos result = new BlockPos(pos.getX(),pos.getY()-1,pos.getZ());
        //Darkshard
        int Comp1 = getCount(craftingblocks, Deathblocks.redsteelblock);
        int Comp2 = getCount(craftingblocks, Blocks.OBSIDIAN);
        int Comp3 = 0;
        int Comp4 = 0;
        if(Comp1 == 4 ||Comp2 == 4 ||Comp3 == 0 ||Comp4 == 0) {
            worldIn.setBlockState(result, (IBlockState) Blocks.ANVIL);
            setToAir(craftingpos, worldIn);
            return;
        }
        
            
    }

    private void setToAir(ArrayList<BlockPos> craftingpos, World worldIn) {
        worldIn.setBlockToAir(craftingpos.get(0));
        worldIn.setBlockToAir(craftingpos.get(1));
        worldIn.setBlockToAir(craftingpos.get(2));
        worldIn.setBlockToAir(craftingpos.get(3));
        worldIn.setBlockToAir(craftingpos.get(4));
        worldIn.setBlockToAir(craftingpos.get(5));
        worldIn.setBlockToAir(craftingpos.get(6));
        worldIn.setBlockToAir(craftingpos.get(7));
        
    }

    private int getCount(ArrayList<Block> craftingblocks,Block block) {
        int Cound = 0;
        if(craftingblocks.get(0) == block)
            Cound++;
        if(craftingblocks.get(1) == block)
            Cound++;
        if(craftingblocks.get(2) == block)
            Cound++;
        if(craftingblocks.get(3) == block)
            Cound++;
        if(craftingblocks.get(4) == block)
            Cound++;
        if(craftingblocks.get(5) == block)
            Cound++;
        if(craftingblocks.get(6) == block)
            Cound++;
        if(craftingblocks.get(7) == block)
            Cound++;
        return Cound;
    }
}
 

Spoiler

---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 23.03.19 10:45
Description: Unexpected error

java.lang.ClassCastException: net.minecraft.block.state.BlockStateContainer$StateImplementation cannot be cast to net.minecraft.block.Block
    at de.toocrazy007.reddeathmod.blocks.DeathCrafter.onBlockActivated(DeathCrafter.java:47)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:442)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118)
    at net.minecraft.client.Minecraft.run(Minecraft.java:406)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at de.toocrazy007.reddeathmod.blocks.DeathCrafter.onBlockActivated(DeathCrafter.java:47)
    at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:442)
    at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603)
    at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281)
    at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player914'/268, l='MpServer', x=-70,48, y=78,00, z=-49,75]]
    Chunk stats: MultiplayerChunkCache: 1038, 1038
    Level seed: 0
    Level generator: ID 00 - default, ver 1. Features enabled: false
    Level generator options: 
    Level spawn location: World: (-17,64,427), Chunk: (at 15,4,11 in -2,26; contains blocks -32,0,416 to -17,255,431), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 36213 game time, 36213 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 130 total; [EntitySkeleton['Skeleton'/512, l='MpServer', x=-71,50, y=26,00, z=-15,50], EntityZombie['Zombie'/521, l='MpServer', x=-78,50, y=20,00, z=13,50], EntityBat['Bat'/522, l='MpServer', x=-77,47, y=18,76, z=4,45], EntityCreeper['Creeper'/269, l='MpServer', x=-74,54, y=54,00, z=-51,16], EntitySkeleton['Skeleton'/270, l='MpServer', x=-69,50, y=52,00, z=-48,50], EntityPig['Pig'/533, l='MpServer', x=-121,68, y=74,00, z=7,50], EntityPig['Pig'/534, l='MpServer', x=-110,70, y=73,00, z=-9,39], EntityBat['Bat'/535, l='MpServer', x=-66,50, y=30,62, z=-42,16], EntityBat['Bat'/536, l='MpServer', x=-64,34, y=32,09, z=-36,86], EntitySkeleton['Skeleton'/537, l='MpServer', x=-75,50, y=36,00, z=-47,50], EntitySkeleton['Skeleton'/538, l='MpServer', x=-66,50, y=52,00, z=-47,50], EntitySpider['Spider'/539, l='MpServer', x=-87,50, y=27,00, z=-1,50], EntityBat['Bat'/540, l='MpServer', x=-64,48, y=13,90, z=-26,48], EntitySquid['Squid'/541, l='MpServer', x=-68,86, y=59,62, z=-20,30], EntitySkeleton['Skeleton'/542, l='MpServer', x=-60,23, y=70,00, z=-46,52], EntityChicken['Chicken'/544, l='MpServer', x=-111,44, y=72,00, z=-35,78], EntityItem['item.item.egg'/545, l='MpServer', x=-110,71, y=72,00, z=-35,13], EntityCreeper['Creeper'/546, l='MpServer', x=-88,50, y=23,00, z=-63,50], EntityBat['Bat'/547, l='MpServer', x=-77,66, y=36,14, z=-52,19], EntityBat['Bat'/548, l='MpServer', x=-78,49, y=26,35, z=-55,38], EntityZombie['Zombie'/549, l='MpServer', x=-80,50, y=45,00, z=-61,50], EntityBat['Bat'/550, l='MpServer', x=-91,48, y=53,68, z=-50,34], EntityZombie['Zombie'/551, l='MpServer', x=-78,30, y=23,00, z=-79,70], EntityCreeper['Creeper'/552, l='MpServer', x=-74,50, y=46,00, z=-73,50], EntityZombie['Zombie'/553, l='MpServer', x=-92,50, y=23,00, z=-66,50], EntityZombie['Zombie'/554, l='MpServer', x=-87,50, y=23,00, z=-66,50], EntitySkeleton['Skeleton'/555, l='MpServer', x=-94,50, y=32,00, z=-65,50], EntityZombie['Zombie'/556, l='MpServer', x=-94,50, y=42,00, z=-75,50], EntityZombie['Zombie'/557, l='MpServer', x=-94,50, y=42,00, z=-75,50], EntityZombie['Zombie'/558, l='MpServer', x=-81,53, y=32,00, z=-68,73], EntitySkeleton['Skeleton'/559, l='MpServer', x=-85,53, y=50,00, z=-75,22], EntityZombie['Zombie'/560, l='MpServer', x=-78,65, y=23,00, z=-83,65], EntityZombie['Zombie'/561, l='MpServer', x=-73,50, y=23,00, z=-83,50], EntityZombie['Zombie'/562, l='MpServer', x=-74,70, y=23,00, z=-82,30], EntitySkeleton['Skeleton'/563, l='MpServer', x=-78,50, y=23,00, z=-82,50], EntityCreeper['Creeper'/564, l='MpServer', x=-79,38, y=19,00, z=-87,01], EntityBat['Bat'/565, l='MpServer', x=-74,50, y=23,79, z=-80,31], EntitySkeleton['Skeleton'/566, l='MpServer', x=-77,50, y=22,00, z=-88,50], EntitySquid['Squid'/1079, l='MpServer', x=-34,40, y=60,80, z=-101,54], EntitySquid['Squid'/1080, l='MpServer', x=-34,84, y=59,63, z=-113,34], EntitySquid['Squid'/1081, l='MpServer', x=-29,40, y=61,54, z=-108,10], EntityPlayerSP['Player914'/268, l='MpServer', x=-70,48, y=78,00, z=-49,75], EntityCreeper['Creeper'/587, l='MpServer', x=-11,50, y=27,00, z=-3,50], EntityChicken['Chicken'/591, l='MpServer', x=-22,87, y=64,00, z=25,49], EntitySkeleton['Skeleton'/599, l='MpServer', x=-62,50, y=27,00, z=5,50], EntityZombie['Zombie'/600, l='MpServer', x=-60,50, y=27,00, z=11,50], EntityZombie['Zombie'/601, l='MpServer', x=-59,50, y=27,00, z=9,50], EntityZombie['Zombie'/602, l='MpServer', x=-59,50, y=28,00, z=0,50], EntityZombie['Zombie'/603, l='MpServer', x=-48,30, y=40,00, z=6,50], EntityChicken['Chicken'/604, l='MpServer', x=-37,16, y=64,00, z=-16,50], EntityChicken['Chicken'/605, l='MpServer', x=-45,40, y=66,00, z=-2,12], EntityChicken['Chicken'/606, l='MpServer', x=-45,72, y=66,00, z=-7,49], EntityChicken['Chicken'/607, l='MpServer', x=-34,13, y=64,00, z=-10,35], EntityItem['item.item.egg'/608, l='MpServer', x=-34,09, y=64,00, z=-10,21], EntityItem['item.item.egg'/609, l='MpServer', x=-45,51, y=66,00, z=-1,98], EntityItem['item.item.egg'/610, l='MpServer', x=-45,56, y=66,00, z=-7,85], EntityZombie['Zombie'/611, l='MpServer', x=-0,50, y=29,00, z=-32,50], EntityBat['Bat'/612, l='MpServer', x=-6,25, y=16,10, z=-44,25], EntitySkeleton['Skeleton'/613, l='MpServer', x=-0,50, y=33,00, z=-44,50], EntityZombie['Zombie'/614, l='MpServer', x=-12,50, y=43,00, z=-33,50], EntityCreeper['Creeper'/615, l='MpServer', x=-1,50, y=33,00, z=-43,50], EntitySkeleton['Skeleton'/616, l='MpServer', x=-19,23, y=31,00, z=-5,54], EntityItem['item.item.egg'/617, l='MpServer', x=-31,92, y=63,00, z=-14,54], EntitySkeleton['Skeleton'/618, l='MpServer', x=-12,50, y=43,00, z=-31,50], EntityCreeper['Creeper'/619, l='MpServer', x=-10,50, y=43,00, z=-31,50], EntityZombie['Zombie'/623, l='MpServer', x=-50,50, y=28,00, z=-16,50], EntitySkeleton['Skeleton'/629, l='MpServer', x=-59,50, y=26,00, z=-2,50], EntityCreeper['Creeper'/630, l='MpServer', x=-56,50, y=28,00, z=-4,50], EntityCreeper['Creeper'/631, l='MpServer', x=-49,50, y=24,00, z=-7,50], EntityZombie['Zombie'/632, l='MpServer', x=-53,50, y=24,00, z=-6,50], EntityZombie['Zombie'/633, l='MpServer', x=-51,50, y=24,00, z=-2,50], EntityZombie['Zombie'/634, l='MpServer', x=-59,50, y=30,00, z=-0,50], EntityZombie['Zombie'/635, l='MpServer', x=-58,50, y=30,00, z=-2,50], EntityCreeper['Creeper'/636, l='MpServer', x=-22,50, y=37,00, z=-38,50], EntityCreeper['Creeper'/637, l='MpServer', x=-19,50, y=37,00, z=-42,50], EntityCreeper['Creeper'/638, l='MpServer', x=-19,50, y=37,00, z=-43,50], EntityChicken['Chicken'/642, l='MpServer', x=-34,68, y=62,70, z=-71,89], EntityItem['item.item.egg'/643, l='MpServer', x=-35,11, y=61,00, z=-75,65], EntityChicken['Chicken'/644, l='MpServer', x=-12,83, y=68,00, z=-82,51], EntityChicken['Chicken'/645, l='MpServer', x=-25,81, y=66,00, z=-92,89], EntityChicken['Chicken'/646, l='MpServer', x=-26,80, y=67,00, z=-88,52], EntityItem['item.item.egg'/647, l='MpServer', x=-17,34, y=67,00, z=-81,71], EntityItem['item.item.egg'/648, l='MpServer', x=-25,62, y=66,00, z=-93,21], EntityItem['item.item.egg'/649, l='MpServer', x=-26,79, y=67,00, z=-89,05], EntityChicken['Chicken'/656, l='MpServer', x=-17,78, y=66,00, z=-79,45], EntityItem['item.item.egg'/657, l='MpServer', x=-17,96, y=66,00, z=-79,38], EntityChicken['Chicken'/662, l='MpServer', x=-29,50, y=68,00, z=-87,84], EntityChicken['Chicken'/663, l='MpServer', x=-28,50, y=64,00, z=-101,50], EntitySquid['Squid'/665, l='MpServer', x=-33,21, y=62,49, z=-110,25], EntityPig['Pig'/410, l='MpServer', x=-149,82, y=72,00, z=4,20], EntityPig['Pig'/412, l='MpServer', x=-141,39, y=73,00, z=-13,32], EntityPig['Pig'/413, l='MpServer', x=-138,67, y=73,00, z=-13,51], EntityPig['Pig'/414, l='MpServer', x=-132,79, y=70,90, z=-10,85], EntityPig['Pig'/415, l='MpServer', x=-143,31, y=73,00, z=-23,27], EntityCreeper['Creeper'/927, l='MpServer', x=-94,50, y=31,00, z=-62,50], EntityCreeper['Creeper'/673, l='MpServer', x=-66,50, y=30,00, z=-63,50], EntityPig['Pig'/419, l='MpServer', x=-131,49, y=73,00, z=8,29], EntitySkeleton['Skeleton'/935, l='MpServer', x=-88,50, y=53,00, z=-49,50], EntityPig['Pig'/424, l='MpServer', x=-122,51, y=71,00, z=-45,34], EntityCreeper['Creeper'/936, l='MpServer', x=-89,50, y=53,00, z=-52,50], EntityPig['Pig'/425, l='MpServer', x=-124,20, y=72,00, z=-67,31], EntityChicken['Chicken'/426, l='MpServer', x=-112,58, y=71,00, z=-49,12], EntityItem['item.item.egg'/427, l='MpServer', x=-112,97, y=71,00, z=-49,52], EntityPig['Pig'/432, l='MpServer', x=-134,29, y=74,00, z=-17,51], EntityPig['Pig'/433, l='MpServer', x=-136,26, y=74,00, z=-18,65], EntityPig['Pig'/434, l='MpServer', x=-134,28, y=74,00, z=-18,76], EntityPig['Pig'/435, l='MpServer', x=-140,61, y=73,00, z=-24,75], EntityCreeper['Creeper'/691, l='MpServer', x=5,50, y=28,00, z=-5,50], EntityChicken['Chicken'/436, l='MpServer', x=-119,50, y=71,00, z=-47,50], EntityChicken['Chicken'/437, l='MpServer', x=-121,17, y=72,00, z=-41,54], EntitySpider['Spider'/693, l='MpServer', x=2,50, y=28,00, z=-4,50], EntityItem['item.item.egg'/438, l='MpServer', x=-119,31, y=71,00, z=-47,09], EntitySkeleton['Skeleton'/694, l='MpServer', x=1,50, y=28,00, z=-5,50], EntityZombie['Zombie'/439, l='MpServer', x=-105,50, y=27,00, z=-60,50], EntityZombie['Zombie'/695, l='MpServer', x=4,56, y=35,00, z=-12,27], EntityZombie['Zombie'/440, l='MpServer', x=-106,50, y=27,00, z=-60,50], EntityZombie['Zombie'/441, l='MpServer', x=-100,50, y=33,00, z=-63,50], EntityCreeper['Creeper'/442, l='MpServer', x=-103,50, y=36,00, z=-63,50], EntityPig['Pig'/443, l='MpServer', x=-104,28, y=70,00, z=-48,81], EntityBat['Bat'/956, l='MpServer', x=-17,40, y=35,05, z=-8,37], EntityBat['Bat'/448, l='MpServer', x=-109,80, y=34,55, z=-109,75], EntityBat['Bat'/449, l='MpServer', x=-106,36, y=33,66, z=-93,32], EntityPig['Pig'/450, l='MpServer', x=-119,47, y=72,00, z=-67,32], EntityBat['Bat'/455, l='MpServer', x=-107,43, y=37,10, z=-116,25], EntityZombie['Zombie'/711, l='MpServer', x=0,50, y=21,00, z=5,50], EntityChicken['Chicken'/714, l='MpServer', x=6,83, y=64,00, z=-60,54], EntityZombie['Zombie'/716, l='MpServer', x=4,27, y=34,00, z=-44,46], EntityBat['Bat'/1005, l='MpServer', x=-3,76, y=26,52, z=-3,72], EntitySkeleton['Skeleton'/510, l='MpServer', x=-82,50, y=30,00, z=3,50], EntityBat['Bat'/511, l='MpServer', x=-74,44, y=11,17, z=-9,99]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2779)
    at net.minecraft.client.Minecraft.run(Minecraft.java:435)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
    Minecraft Version: 1.10.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_181, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 442850880 bytes (422 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
    FML: MCP 9.32 Powered by Forge 12.18.3.2185 4 mods loaded, 4 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA    mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAAAA    FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.3.2185.jar) 
    UCHIJAAAA    Forge{12.18.3.2185} [Minecraft Forge] (forgeSrc-1.10.2-12.18.3.2185.jar) 
    UCHIJAAAA    reddeathmod{1.0} [Reddeathmod Mod] (bin) 
    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 399.24' Renderer: 'GeForce GTX 1050 Ti/PCIe/SSE2'
    Launched Version: 1.10.2
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 1050 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 399.24, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (United Kingdom)
    Profiler Position: N/A (disabled)
    CPU: 4x AMD A8-7600 Radeon R7, 10 Compute Cores 4C+6G 

 

Edited by toocrazy
Posted
49 minutes ago, toocrazy said:

craftingblocks.add(0, (Block) worldIn.getBlockState(block1));

A BlockState is not a block. It is a combination of Block + metadata + other values.

Are you using an IDE to write your mod?

Do you know Java?

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.