Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ArmamentHaki

Members
  • Joined

  • Last visited

Everything posted by ArmamentHaki

  1. Thanks for the Explanation. I have now found a working way to shoot my projectile in a direction. However, when I do this, the Position is only updated around every ten blocks which makes it look like it is teleporting. It only updates the Position every 1 or 2 seconds, and when it does, the entity is already gone. I tried it with smaller velocity, but that just has the same effect only that it doesn't teleport as far. Here is my class: package net.zeldadungeons.init.entity.projectile; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.client.event.sound.SoundEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.zeldadungeons.util.Log; public class EntitySlingshotPellet extends Entity implements IProjectile { private Entity shootingEntity; private boolean inGround; private int ticksInGround; private int ticksInAir; public EntitySlingshotPellet(World worldIn) { super(worldIn); this.setSize(0.5F, 0.5F); } public EntitySlingshotPellet(World worldIn, double x, double y, double z) { this(worldIn); this.setPosition(x, y, z); } public EntitySlingshotPellet(World worldIn, EntityLivingBase shooter) { this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ); this.shootingEntity = shooter; //throws Entity towards a direction this.setAim(shooter, shooter.rotationPitch, shooter.rotationYaw, 1F, 1F, 0); } public void setAim(Entity shooter, float pitch, float yaw, float p_184547_4_, float velocity, float inaccuracy) { //yaw and pitch are converted into motion values float f = -MathHelper.sin(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F); float f1 = -MathHelper.sin(pitch * 0.017453292F); float f2 = MathHelper.cos(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F); this.setThrowableHeading((double)f, (double)f1, (double)f2, velocity, inaccuracy); this.motionX += shooter.motionX; this.motionZ += shooter.motionZ; if (!shooter.onGround) { this.motionY += shooter.motionY; } Log.getLogger().info("setAim " + f + " " + f1 + " " + f2); } public void onUpdate() { super.onUpdate(); //test whether the Entity is touching the Ground BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ); IBlockState iblockstate = this.world.getBlockState(blockpos); Block block = iblockstate.getBlock(); if (iblockstate.getMaterial() != Material.AIR) { AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(this.world, blockpos); if (axisalignedbb != Block.NULL_AABB && axisalignedbb.offset(blockpos).contains(new Vec3d(this.posX, this.posY, this.posZ))) { //if in Ground, the entity won't move anymore this.inGround = true; motionX = 0; motionY = 0; motionZ = 0; int j = block.getMetaFromState(iblockstate); if (!this.world.collidesWithAnyBlock(this.getEntityBoundingBox().grow(0.05D))) { this.inGround = false; this.ticksInGround = 0; this.ticksInAir = 0; } else { ++this.ticksInGround; this.doBlockCollisions(); } } } //increases the time in air counter if(!this.inGround) { ticksInAir++; } //updates entities position, is executed every tick posX += motionX; posY += motionY; posZ += motionZ; //sets the position this.setPosition(posX, posY, posZ); Log.getLogger().info((int)posX + " " + (int)posY + " " + (int)posZ + " " + motionX + " "+ motionY + " " + motionZ); this.removeEntity(); } public void removeEntity() { //responsible for removing the entity after it hits the ground if (this.ticksInGround >= 10) { this.setDead(); this.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY+0.5D, this.posZ, 1.0D, 0.0D, 1.0D, 10); } } @SideOnly(Side.CLIENT) @Override public boolean isInRangeToRenderDist(double distance) { double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 10.0D; if (Double.isNaN(d0)) { d0 = 1.0D; } d0 = d0 * 64.0D * getRenderDistanceWeight(); return distance < d0 * d0; } @Override public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { float f = MathHelper.sqrt(x*x + y*y + z*z); x = x / (double)f; y = y / (double)f; z = z / (double)f; //velocity is added this.motionX = x*velocity; this.motionY = y*velocity; this.motionZ = z*velocity; Log.getLogger().info("throw " + f + " " + x + " " + y + " " + z); } @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound compound) { } @Override protected void writeEntityToNBT(NBTTagCompound compound) { } } Edit:This seem to be some kind of Client-Server side error as on the server, the position is updated properly, the position updates every 20 ticks on the client
  2. By every possible direction, I meant that the projectile acts like an arrow that can be shot in every direction and acts the same. And if I used motionX*motionX+motionY*motionY = 0.25 it should be useful as it would show that the actual way which is taken by the Entity is 0.5 Blocks long, wouldn't it?
  3. Ok so what I planned to do is get rotationYaw and rotation Pitch from the EntityPlayer that shoots my projectile, just like EntityArrow does. However, I dont understand the calculations that are then used by Minecraft. My plan was to always make the projectile move 0.5 Blocks every tick but in every possible direction. The problem is that motionX and motionY already define how fast it goes, so depending on how the player is rotated, the projectile will go faster or slower. I had an idea on how to solve this: motionX*motionX + motionY*motionY would have to be 0.25, basically the sentence of pythagoras. But how can I relate my roationPitch and my rotationYaw to motion? Using sinus may work.. Also, is MathHelper.sqrt the function that gets the root of a value? I am not that good with english mathematical expressions
  4. Of Course .player is null, The player entity is only being constructed on this event or later
  5. I think you could subscribe to one of the Key Events, like Key Input event
  6. All right. So basically, the xmotion shows how fast an entity moves into direction x. If a Position was calculated by x*x, the motion would be 2x?
  7. I am here with another question. My Entity / Projectile class is down below. I already managed to simulate gravity and decaying my entity after falling onto the ground, however I have no clue on how to use the Motion variables. Does someone know how Minecraft uses them? I already looked up the arrow class, but didn't really understand the process. As an example, I want to shoot my entity into a specified direction, starting at fast Speed and then slowing down. package net.zeldadungeons.init.entity.projectile; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.client.event.sound.SoundEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.zeldadungeons.util.Log; public class EntitySlingshotPellet extends Entity implements IProjectile { private Entity shootingEntity; private boolean inGround; private int ticksInGround; private int ticksInAir; public EntitySlingshotPellet(World worldIn) { super(worldIn); this.setSize(0.5F, 0.5F); } public EntitySlingshotPellet(World worldIn, double x, double y, double z) { this(worldIn); this.setPosition(x, y, z); } public EntitySlingshotPellet(World worldIn, EntityLivingBase shooter) { this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ); this.shootingEntity = shooter; } public void onUpdate() { super.onUpdate(); BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ); IBlockState iblockstate = this.world.getBlockState(blockpos); Block block = iblockstate.getBlock(); if (iblockstate.getMaterial() != Material.AIR) { AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(this.world, blockpos); if (axisalignedbb != Block.NULL_AABB && axisalignedbb.offset(blockpos).contains(new Vec3d(this.posX, this.posY, this.posZ))) { this.inGround = true; } } if (this.inGround) { int j = block.getMetaFromState(iblockstate); if (!this.world.collidesWithAnyBlock(this.getEntityBoundingBox().grow(0.05D))) { this.inGround = false; this.motionX *= (double)(this.rand.nextFloat() * 0.2F); this.motionY *= (double)(this.rand.nextFloat() * 0.2F); this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } else { ++this.ticksInGround; this.doBlockCollisions(); } } else { this.posY = posY - 0.4D; ticksInAir++; } if (this.ticksInGround >= 10) { this.setDead(); this.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY+0.5D, this.posZ, 1.0D, 0.0D, 1.0D, 10); } this.setPosition(posX, posY, posZ); } @SideOnly(Side.CLIENT) @Override public boolean isInRangeToRenderDist(double distance) { double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 10.0D; if (Double.isNaN(d0)) { d0 = 1.0D; } d0 = d0 * 64.0D * getRenderDistanceWeight(); return distance < d0 * d0; } @Override public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { } @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound compound) { } @Override protected void writeEntityToNBT(NBTTagCompound compound) { } }
  8. It seems that apparently, it was the spawn egg which wouldn't work... I just tried to summon it with a command and it worked fine, should've done it before.
  9. I Created a Basic Entity. I get no Errors on the console, however, the entity does not Show up ingame. Is there something missing for an Entity in my classes? Entity Class package net.zeldadungeons.init.entity.projectile; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.IProjectile; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class EntitySlingshotPellet extends Entity implements IProjectile { public EntitySlingshotPellet(World worldIn) { super(worldIn); } @Override public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { } @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound compound) { } @Override protected void writeEntityToNBT(NBTTagCompound compound) { } } Model Class package net.zeldadungeons.client.render.entity.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.zeldadungeons.init.entity.projectile.EntitySlingshotPellet; public class ModelSlingshotPellet extends ModelBase { ModelRenderer c1; public ModelSlingshotPellet() { textureWidth = 32; textureHeight = 32; c1 = new ModelRenderer(this, 0, 0); c1.addBox(0F, 0F, 0F, 3, 3, 3); c1.setRotationPoint(0F, 0F, 0F); c1.setTextureSize(32, 32); c1.mirror = true; setRotation(c1, 0F, 0F, 0F); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); c1.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } Render Class(I am really unsure how the render method works so that may be the actual issue) package net.zeldadungeons.client.render.entity; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityBoat; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.zeldadungeons.ZeldaDungeons; import net.zeldadungeons.client.render.entity.model.ModelSlingshotPellet; import net.zeldadungeons.init.entity.projectile.EntitySlingshotPellet; public class RenderSlingshotPellet extends Render<EntitySlingshotPellet> { private static ModelSlingshotPellet model = new ModelSlingshotPellet(); private static final ResourceLocation SLINGSHOT_PELLET = new ResourceLocation(ZeldaDungeons.MODID, "textures/entities/slingshot_pellet.png"); public RenderSlingshotPellet(RenderManager renderManager) { super(renderManager); } public void doRender(EntitySlingshotPellet entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); this.setupTranslation(x, y, z); this.bindTexture(SLINGSHOT_PELLET); if (this.renderOutlines) { GlStateManager.enableColorMaterial(); } this.model.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); if (this.renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); } @Override protected ResourceLocation getEntityTexture(EntitySlingshotPellet entity) { return SLINGSHOT_PELLET; } public void setupTranslation(double p_188309_1_, double p_188309_3_, double p_188309_5_) { GlStateManager.translate((float) p_188309_1_, (float) p_188309_3_ + 0.375F, (float) p_188309_5_); } } My Registry should be fine.
  10. Thank you. In the end, it was my json which was pointing to the wrong texture file, which I should have realised earlier as it was in the console the whole time. I will change the other things now
  11. cps

    ArmamentHaki replied to ejer's topic in Modder Support
    The Thing with modding is is that you will be completely bad at it even if you know java. Understanding Minecraft is at least as important. Everyone started at some point, Forum Moderators like diesieben or Choonster learnt it just as we do now. So where is the point in complaining whether somebody can code or not? You learn while you practise, at least that is how I do it.
  12. Okay, until now I already changed quite a bit of code, but my former Problem is still remaining. I am probably loading the Model in a wrong way. Here is the class that Manages my Item and Block models: package net.zeldadungeons.init; import net.zeldadungeons.ZeldaDungeons; import net.zeldadungeons.init.blocks.BlockPressureSwitch; import net.zeldadungeons.util.MeshDefinitionFix; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod.EventBusSubscriber(value = Side.CLIENT, modid = ZeldaDungeons.MODID) public class Modelizer { public static final Modelizer INSTANCE = new Modelizer(); @SubscribeEvent public static void registerAll(final ModelRegistryEvent e) { INSTANCE.registerItemModels(); INSTANCE.registerBlockModels(); } private void registerItemModels() { } private void registerBlockModels(){ registerBlockItemModel(Blockizer.PRESSURE_SWITCH.getDefaultState()); } private void registerItemModel(Item item) { final ModelResourceLocation resource = new ModelResourceLocation(item.getRegistryName(), "inventory"); ModelBakery.registerItemVariants(item, resource); ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> resource)); ModelLoader.setCustomModelResourceLocation(item, 0, resource); } private void registerBlockItemModel(final IBlockState state) { final Block block = state.getBlock(); final Item item = Item.getItemFromBlock(block); if (item != Items.AIR) { registerItemModel(item); } } } I have no normal Items yet, so that the registerItemModels method is empty. However, my Block Item Models are the Problem.
  13. You could make your quiver extend Arrow and then you would only need to make sure that instead of the quiver, its arrows are consumed. Otherwise I am not sure how this would work as you cannot change Minecrafts Code directly. Or you could iterate through your inventory until a quiver with one arrow is found. Again, I am not sure if this works in practise.
  14. Try to return "shouldSideBeRendered()" true or test if it does return true. Also, setGraphicsLevel() changes leavesFancy, and I think that Minecraft normally renders the leaves transparent if it is true
  15. Just create a Method that reduces your arrow count every time you shoot with your bow. If the Arrow NBT is 0, no arrows can be shot anymore. I think there are similar Methods existing, something like consumeItem() if I remember correctly. You should post more exact on what your problem is and show your Code. Maybe you could also use item capabilities for this
  16. Hi, I got back into modding some time ago and I am having Problems once again with my json files. I was trying to create a block with different variants, which I succeeded in now, but however the ItemBlock still doesn't render properly. I already used a formatter and it said that all jsons are valid. Furthermore, the console shows no error, although I already know that it accesses the Jsons. And I also searched for spelling mistakes and if all textures were where they belonged to the last two hours. Json "pressure_switch" in blockstates folder { "forge_marker": 1, "defaults": { "model": "minecraft:cube_all" }, "variants": { "variant": { "a": { "textures": { "all": "zeldadungeons:blocks/pressure_switch.a" } }, "b": { "textures": { "all": "zeldadungeons:blocks/pressure_switch.b" } } } } } Json "pressure_switch" in models/block folder { "parent": "minecraft:block/block" } Json "pressure_switch" in models/item folder { "parent": "zeldadungeons:block/pressure_switch", "textures": { "layer0": "zeldadungeons:items/pressure_switch.a" } } This is ingame:
  17. All done. However, my game crashes upon initializing the Items. This happens because when an ItemCard is created, I assign a Card to it, which then can be transferred from the original item into the players' Card reposotory. I guess that it crashes because my Cards aren't registered yet, but Items always get registered second, as it says in the doc, so what should I do? 2017-07-10 18:03:20,609 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-07-10 18:03:20,609 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [18:03:20] [main/INFO] [GradleStart]: Extra: [] [18:03:20] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/luca/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [18:03:21] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [18:03:21] [main/INFO] [FML]: Forge Mod Loader version 14.21.0.2327 for Minecraft 1.12 loading [18:03:21] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_131, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jdk1.8.0_131\jre [18:03:21] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [18:03:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [18:03:21] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin [18:03:21] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [18:03:21] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [18:03:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [18:03:21] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [18:03:23] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [18:03:23] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [18:03:23] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [18:03:24] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [18:03:25] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [18:03:25] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [18:03:25] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} 2017-07-10 18:03:26,402 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-07-10 18:03:27,542 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-07-10 18:03:27,542 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [18:03:28] [main/INFO]: Setting user: Player226 [18:03:34] [main/WARN]: Skipping bad option: lastServer: [18:03:34] [main/INFO]: LWJGL Version: 2.9.4 [18:03:36] [main/INFO] [FML]: -- System Details -- Details: Minecraft Version: 1.12 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_131, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 898984040 bytes (857 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: Loaded coremods (and transformers): GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.2.11481 Compatibility Profile Context' Renderer: 'AMD Radeon HD 7560D' [18:03:36] [main/INFO] [FML]: MinecraftForge v14.21.0.2327 Initialized [18:03:37] [main/INFO] [FML]: Replaced 921 ore ingredients [18:03:37] [main/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [18:03:37] [main/INFO] [FML]: Searching C:\Users\luca\Diebe im Olymp CD\Desktop\Duel Monsters 1.12\DuelMonsters\mods for mods [18:03:39] [main/INFO] [FML]: Forge Mod Loader has identified 5 mods to load [18:03:39] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 615174247 nanos [18:03:40] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, duelmonsters] at CLIENT [18:03:40] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, duelmonsters] at SERVER [18:03:41] [main/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Duel Monsters [18:03:41] [main/INFO] [FML]: Processing ObjectHolder annotations [18:03:41] [main/INFO] [FML]: Found 464 ObjectHolder annotations [18:03:41] [main/INFO] [FML]: Identifying ItemStackHolder annotations [18:03:41] [main/INFO] [FML]: Found 0 ItemStackHolder annotations [18:03:41] [main/INFO] [FML]: Applying holder lookups [18:03:41] [main/INFO] [FML]: Holder lookups applied [18:03:41] [main/INFO] [FML]: Applying holder lookups [18:03:41] [main/INFO] [FML]: Holder lookups applied [18:03:41] [main/INFO] [FML]: Applying holder lookups [18:03:41] [main/INFO] [FML]: Holder lookups applied [18:03:42] [main/INFO] [FML]: Configured a dormant chunk cache size of 0 [18:03:42] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json [18:03:42] [main/INFO] [duelmonsters]: preInit [18:03:42] [main/INFO] [FML]: Applying holder lookups [18:03:42] [main/INFO] [FML]: Holder lookups applied [18:03:42] [main/INFO] [FML]: Injecting itemstacks [18:03:42] [main/INFO] [FML]: Itemstack injection complete [18:03:42] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Found status: OUTDATED Target: 14.21.1.2387 [18:03:48] [Sound Library Loader/INFO]: Starting up SoundSystem... [18:03:48] [Thread-5/INFO]: Initializing LWJGL OpenAL [18:03:48] [Thread-5/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [18:03:49] [Thread-5/INFO]: OpenAL initialized. [18:03:49] [Sound Library Loader/INFO]: Sound engine started [18:03:56] [main/INFO] [FML]: Max texture size: 16384 [18:03:56] [main/INFO]: Created: 16x16 textures-atlas [18:03:58] [main/INFO] [duelmonsters]: initItems [18:03:58] [main/ERROR] [FML]: Fatal errors were detected during the transition from INITIALIZATION to POSTINITIALIZATION. Loading cannot continue [18:03:58] [main/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHI minecraft{1.12} [Minecraft] (minecraft.jar) UCHI mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.0.2327.jar) UCHI forge{14.21.0.2327} [Minecraft Forge] (forgeSrc-1.12-14.21.0.2327.jar) UCHE duelmonsters{alpha 1.0} [Duel Monsters] (bin) [18:03:58] [main/ERROR] [FML]: The following problems were captured during this phase [18:03:58] [main/ERROR] [FML]: Caught exception from Duel Monsters (duelmonsters) java.lang.NullPointerException: null at net.minecraftforge.fml.common.registry.PersistentRegistryManager.makeDelegate(PersistentRegistryManager.java:729) ~[forgeSrc-1.12-14.21.0.2327.jar:?] at net.minecraftforge.fml.common.registry.IForgeRegistryEntry$Impl.<init>(IForgeRegistryEntry.java:70) ~[forgeSrc-1.12-14.21.0.2327.jar:?] at armamenthaki.duelmonsters.duel.Card.<init>(Card.java:13) ~[bin/:?] at armamenthaki.duelmonsters.duel.cards.cardtypes.CardMonster.<init>(CardMonster.java:14) ~[bin/:?] at armamenthaki.duelmonsters.duel.cards.CardSpeedWarrior.<init>(CardSpeedWarrior.java:13) ~[bin/:?] at armamenthaki.duelmonsters.init.Itemizer.initItems(Itemizer.java:28) ~[bin/:?] at armamenthaki.duelmonsters.DuelMonsters.init(DuelMonsters.java:59) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:643) ~[forgeSrc-1.12-14.21.0.2327.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?] at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?] at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:252) ~[forgeSrc-1.12-14.21.0.2327.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:230) ~[forgeSrc-1.12-14.21.0.2327.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?] at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?] at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:147) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:830) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:358) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:571) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:411) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] [18:03:58] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ---- // On the bright side, I bought you a teddy bear! Time: 7/10/17 6:03 PM Description: There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Duel Monsters (duelmonsters) Caused by: java.lang.NullPointerException at net.minecraftforge.fml.common.registry.PersistentRegistryManager.makeDelegate(PersistentRegistryManager.java:729) at net.minecraftforge.fml.common.registry.IForgeRegistryEntry$Impl.<init>(IForgeRegistryEntry.java:70) at armamenthaki.duelmonsters.duel.Card.<init>(Card.java:13) at armamenthaki.duelmonsters.duel.cards.cardtypes.CardMonster.<init>(CardMonster.java:14) at armamenthaki.duelmonsters.duel.cards.CardSpeedWarrior.<init>(CardSpeedWarrior.java:13) at armamenthaki.duelmonsters.init.Itemizer.initItems(Itemizer.java:28) at armamenthaki.duelmonsters.DuelMonsters.init(DuelMonsters.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:643) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:252) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:230) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:147) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:830) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:358) at net.minecraft.client.Minecraft.init(Minecraft.java:571) at net.minecraft.client.Minecraft.run(Minecraft.java:411) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.12 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_131, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 662075416 bytes (631 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.40 Powered by Forge 14.21.0.2327 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHI minecraft{1.12} [Minecraft] (minecraft.jar) UCHI mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.0.2327.jar) UCHI forge{14.21.0.2327} [Minecraft Forge] (forgeSrc-1.12-14.21.0.2327.jar) UCHE duelmonsters{alpha 1.0} [Duel Monsters] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.2.11481 Compatibility Profile Context' Renderer: 'AMD Radeon HD 7560D' [18:03:58] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\luca\Desktop\Duel Monsters 1.12\DuelMonsters\.\crash-reports\crash-2017-07-10_18.03.58-client.txt AL lib: (EE) alc_cleanup: 1 device not closed [0x7FEE55CAAA0] ANOMALY: meaningless REX prefix used [0x7FEE55B48C0] ANOMALY: meaningless REX prefix used [0x7FEE55B8BE0] ANOMALY: meaningless REX prefix used
  18. Sorry for bothering, but I still get an error when recompiling: This is what I changed: Deleted CardRegistry class Added Registries class: package armamenthaki.duelmonsters; import armamenthaki.duelmonsters.duel.Card; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.IForgeRegistry; public class Registries { public static final IForgeRegistry<Card> CARDREGISTRY = GameRegistry.findRegistry(Card.class); //error at <Card> } Also, I changed the Card class: //I'll cut off the unimportant stuff public class Card extends IForgeRegistryEntry.Impl { private String name; private int id; private ResourceLocation resource; //this is a resource location is used earlier for a GUI And thats what I changed in the EventHandler: @SubscribeEvent public static void registerCardRegistry(RegistryEvent.NewRegistry e) { RegistryBuilder regBuilder = new RegistryBuilder(); regBuilder.setType(Card.class); regBuilder.setName(new ResourceLocation (DuelMonsters.MODID, "cards")); regBuilder.setIDRange(0, 1000); regBuilder.create(); } @SubscribeEvent public static void registerCards(RegistryEvent.Register<Card> e) { Card speedwarrior = new CardSpeedWarrior(); //example registry e.getRegistry().register(speedwarrior); }
  19. So, thanks to your advice I tried creating a new Registry, the "CardRegistry". But, because of my lack of experience in modding and not really understanding the docs I will Show you what I have done so far. Hopefully it's not completely wrong: I began with creating a new method in my main EventHandler, which should be called to Register my Card Registry. There, I created a RegistryBuilder and used ist methods to define my Registry. However, I don't really understand the setName() and setDefaultKey methods, and in the doc it said that it would have something to do with registryNames. @SubscribeEvent public static void registerCardRegistry(RegistryEvent.NewRegistry e) { RegistryBuilder regBuilder = new RegistryBuilder(); regBuilder.setType(Card.class); regBuilder.setName(new ResourceLocation(DuelMonsters.MODID, "textures/cards")); regBuilder.setIDRange(0, 1000); regBuilder.setDefaultKey(new ResourceLocation (DuelMonsters.MODID, "textures/cards")); regBuilder.create(); } After that, I created a CardRegistry class, implementing IForgeRegistryEntry: package armamenthaki.duelmonsters; import java.util.Iterator; import java.util.List; import java.util.Set; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.IForgeRegistry; import net.minecraftforge.fml.common.registry.IForgeRegistryEntry; public class CardRegistry<T> implements IForgeRegistryEntry<T> { @Override public T setRegistryName(ResourceLocation name) { return null; } @Override public ResourceLocation getRegistryName() { return null; } @Override public Class<T> getRegistryType() { return null; } } At last, I tried this for the future registries of my Cards: @SubscribeEvent public static void registerCards(RegistryEvent.Register e) { } I think I Need to inform myself about type Parameters, because I didn't manage to define a certain registry Event here. Still, is this a right way to do it, or is it completely wrong? Edit: Yes, my Cards have a unique ID and Names, so it would be possible to do something like Card card; if(message.id == 1) { card = new CardExample(); } , but I think it would be a very long method as I am planning to add many more Cards. Also, I think registering is a better way to do it.
  20. So what I did was -use the packet I receive in the handler -understand how packets work -add the empty constructor -remove the REQ Argument Thanks a lot, so far that really helped me out, mainly because I understand how it works now! But I still have some Problems. First off, how else should I write the objects to Bytes? What do you mean by identifier, because I don't know how to acces an identifier of an object. Then, does the Forge Registry also allow to Register non-Minecraft things? If so, that would also solve my Problem.
  21. Fine, I did that and it helped me. However I have a question. After I use the sendTo() command, what will the packet do? How can I Change for example an Attribute of a class based on the packet? package armamenthaki.duelmonsters.network.message; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.ArrayList; import armamenthaki.duelmonsters.duel.Card; import armamenthaki.duelmonsters.network.MessageBase; import armamenthaki.duelmonsters.util.ByteBufUtil; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; public class PacketCards<REQ> implements IMessage { public static HandlerPacketCards handler = new HandlerPacketCards(); private ArrayList<Card> cards; private ArrayList<Card> cardOP; ByteBufUtil bbu; ArrayList<byte[]> byteArray; private int intention; public PacketCards(ArrayList<Card> arrayCards, int intention) { this.cards = arrayCards; this.intention = intention; } @Override public void fromBytes(ByteBuf buf) { int i = 0; ArrayList<Card> arrayCards = new ArrayList<Card>(); for(Card card: cardOP) { try { buf.readBytes(byteArray.get(i)); Card c = (Card) bbu.bytesToObj(byteArray.get(i)); this.cards.add(c); i++; } catch (ClassNotFoundException | IOException e) { e.printStackTrace(); } } } @Override public void toBytes(ByteBuf buf) { for(Card card: cards) { try { byte[] byteArray = bbu.objToBytes(card); cardOP.add(card); cards.remove(card); buf.writeBytes(byteArray); this.byteArray.add(byteArray); } catch (IOException e) { e.printStackTrace(); } } } static class HandlerPacketCards implements IMessageHandler<PacketCards, IMessage> { @Override public IMessage onMessage(PacketCards message, MessageContext ctx) { if(ctx.side == Side.SERVER) { return new PacketCards(new ArrayList<Card>(), 0); } return null; } } } So, the Logical Server sends this packet object to the Logical Client, doesn't it? But where do I get the ArrayList from that I sent?
  22. I wanted to create a packet which sends one ArrayList of an specific object from the Server to the Client. But first of all I don't understand this REQ-stuff. Has this to do with requests and replies? Next, if I uderstand this right, Networking works the same way in either Singleplayer or Multiplayer, doesn't it? I have an issue regarding the registry of my packet. In Eclipse it says And voilá my classes: package armamenthaki.duelmonsters.network; import java.util.ArrayList; import armamenthaki.duelmonsters.DuelMonsters; import armamenthaki.duelmonsters.duel.Card; import armamenthaki.duelmonsters.individual.capabilities.IDuelData; import armamenthaki.duelmonsters.network.message.HandlerPacketCard; import armamenthaki.duelmonsters.network.message.PacketCard; import armamenthaki.duelmonsters.network.message.PacketCards; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; public class NetworkHandler { private static SimpleNetworkWrapper INSTANCE; public static void init() { INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(DuelMonsters.MODID); INSTANCE.registerMessage(HandlerPacketCard.class, PacketCards.class, 0, Side.SERVER); //error this line } } package armamenthaki.duelmonsters.network.message; import java.util.ArrayList; import armamenthaki.duelmonsters.duel.Card; import armamenthaki.duelmonsters.duel.cards.CardSpeedWarrior; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; public class HandlerPacketCard implements IMessageHandler { @Override public IMessage onMessage(IMessage message, MessageContext ctx) { if(ctx.side == Side.SERVER) { return new PacketCards(new ArrayList<Card>(), 0); } return null; } } package armamenthaki.duelmonsters.network.message; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.ArrayList; import armamenthaki.duelmonsters.duel.Card; import armamenthaki.duelmonsters.network.MessageBase; import armamenthaki.duelmonsters.util.ByteBufUtil; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class PacketCards implements IMessage { private ArrayList<Card> cards; private ArrayList<Card> cardOP; ByteBufUtil bbu; ArrayList<byte[]> byteArray; private int intention; public PacketCards(ArrayList<Card> arrayCards, int intention) { this.cards = arrayCards; this.intention = intention; } @Override public void fromBytes(ByteBuf buf) { int i = 0; ArrayList<Card> arrayCards = new ArrayList<Card>(); for(Card card: cardOP) { try { buf.readBytes(byteArray.get(i)); Card c = (Card) bbu.bytesToObj(byteArray.get(i)); this.cards.add(c); i++; } catch (ClassNotFoundException | IOException e) { e.printStackTrace(); } } } @Override public void toBytes(ByteBuf buf) { for(Card card: cards) { try { byte[] byteArray = bbu.objToBytes(card); cardOP.add(card); cards.remove(card); buf.writeBytes(byteArray); this.byteArray.add(byteArray); } catch (IOException e) { e.printStackTrace(); } } } } To write my Objects to Bytes, I use this ByteBufUtil: package armamenthaki.duelmonsters.util; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; public class ByteBufUtil { public static byte[] objToBytes(Object obj) throws IOException { byte[] bytes = null; ByteArrayOutputStream bos = null; ObjectOutputStream oos = null; try { bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bytes = bos.toByteArray(); } finally { if(oos != null)oos.close(); if(bos != null)bos.close(); } return bytes; } public static Object bytesToObj(byte[] bytes) throws IOException, ClassNotFoundException { Object obj = null; ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { bis = new ByteArrayInputStream(bytes); ois = new ObjectInputStream(bis); obj = ois.readObject(); } finally { if(ois != null)ois.close(); if(bis != null)bis.close(); } return obj; } } Thank you for taking your time to help me.
  23. I am not sure if I understand you correctly, but the file is located in src/main/resources/duelmonsters/textures/textures/gui/cmbase.png. I have two texture Folders, one for textures in General, and one for textures which belong to minecraft related textures. The Resource Location is defined at the beginning of the class.
  24. Hello, it's me again with another Problem on my GUI. The Custom Buttons I made get a Card Attribute to save the Card that they are related to. I wanted to use this in order to construct a new GUI, which is opened when the Player clicks a Card Button. Then I would use this Card as a Parameter in the new GUI, in order to create a Card-Info-File from the data stored in the buttons' Card Attribute. The Problem is that when I open the new Gui, the old one gets closed and all the objects I was referencing seem to then equal null, which is why I get a NullPointerException when I try using the cards' data... Is there a good way to do this? I tried cloning the Card but that wouldn't work either. Then I tried to find out which Card I have to create by comparing the buttons' Card to the Cards the Player owns, and then using the one which is found in the playerCards Array. I will just Show you my GUI-Code, although it is a bit messy, it should still be possible to understand it. package armamenthaki.duelmonsters.gui; import java.util.ArrayList; import java.util.Collection; import armamenthaki.duelmonsters.DuelMonsters; import armamenthaki.duelmonsters.duel.Card; import armamenthaki.duelmonsters.duel.cards.CardSpeedWarrior; import armamenthaki.duelmonsters.individual.capabilities.DuelDataProvider; import armamenthaki.duelmonsters.util.Log; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class GuiDeckEditor extends GuiScreen { //the cards I want to display in the boxes private ArrayList<Card> deck = new ArrayList<Card>(); private ArrayList<Card> displayedCards = new ArrayList<Card>(); //the players cards which out of which the the displayedCards resolves private ArrayList<Card> playerCards = new ArrayList<Card>(); //the background, fixed to the screen width and height private static final ResourceLocation debase = new ResourceLocation("duelmonsters", "textures/textures/gui/guidebase.png"); private ButtonCard clickedButton; private int allCardButtons; private EntityPlayer theplayer; public ResourceLocation guiresource; private ScaledResolution res; private int scroll; private int scroll2; private boolean scrollingUp; private boolean scrollingDown; private int buttonHeight; //controls up and down for both boxes private ButtonControl cardUp; private ButtonControl cardDown; private ButtonControl deckUp; private ButtonControl deckDown; public GuiDeckEditor(EntityPlayer player) { theplayer = player; if(!player.world.isRemote) { //capabilities don't seem to be working as the gui is cient side Log.logString("player"); playerCards = player.getCapability(DuelDataProvider.DUELDAT_CAP, null).getPlayerCards(); playerCards.add(new CardSpeedWarrior()); } //just some cards to add to the screen for testing purposes displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); displayedCards.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); deck.add(new CardSpeedWarrior()); this.mc = Minecraft.getMinecraft(); res = new ScaledResolution(this.mc); } /* basic Gui methods*/ @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { initializeStuff(mouseX, mouseY); drawBackAndForeground(); } @Override public void initGui() { initDisplayedCards(); initDeckCards(); initControls(); } /*this happens in drawScreen*/ public void drawBackAndForeground() { GlStateManager.pushMatrix(); float x = (float)width/512; float y = (float)height/288; int a = res.getScaleFactor(); mc.renderEngine.bindTexture(debase); GlStateManager.scale(x, y, 1.0); GlStateManager.translate(0F, 0F, 2F); this.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 512, 288, 512, 288); GlStateManager.popMatrix(); } public void initializeStuff(int mouseX, int mouseY) { int i = this.buttonList.size()-1; for(; i>=0; i--) { if(this.buttonList.get(i) instanceof ButtonCard) { this.buttonList.remove(i); } } this.initDisplayedCards(); this.initDeckCards(); if(cardUp.dragging)++scroll; if(cardDown.dragging)--scroll; if(deckUp.dragging)++scroll2; if(deckDown.dragging)--scroll2; this.updateControlResources(mouseX, mouseY); cardUp.drawButton(mc); cardDown.drawButton(mc); deckUp.drawButton(mc); deckDown.drawButton(mc); for(GuiButton button : this.buttonList) { if(button instanceof ButtonCard) { ((ButtonCard) button).drawScreen(mc); } } } /*responds to user input*/ @Override public void actionPerformed(GuiButton button) { if(button.id <= allCardButtons && cardUp.hoverState != 1 && cardDown.hoverState != 1) { for(Card card : playerCards) { //this tests if the resourcePath of any players' card equals the buttons' resource, which would mean that they would be the same cards. //however, the capabilities don't work.. if(card.getResource().getResourcePath()==(((ButtonCard) button).getResource().getResourcePath())) { mc.displayGuiScreen(new GuiCardDisplay(this, card)); Log.logString("okokok"); } } } if(button.id == allCardButtons+1) { cardUp.dragging = true; } if(button.id == allCardButtons+2) { cardDown.dragging = true; } if(button.id == allCardButtons+3) { deckUp.dragging = true; } if(button.id == allCardButtons+4) { deckDown.dragging = true; } } /*get and set*/ public int getWidth() { return this.width; } public int getHeight() { return this.height; } /*init for all buttons*/ public void initDisplayedCards() { int line = 0; int column = 0; int id = 0; for(Card itCard : displayedCards) { ResourceLocation resource = itCard.getResource(); int i = width/6 + (column* width/17); int j = (height/6+height/30) + (line* width/13)+this.scroll; float trX = (float)width/6 +(float)(column* width/17); float trY = (float)(height/6+height/30) +(float)(line* width/13)+(float)this.scroll; float sf = (float)width/256F /20F; int rF = res.getScaleFactor(); float fWidth = sf * 256F; float fHeight = sf * 373F; int bWidth = (int)fWidth; int bHeight = (int)fHeight; this.buttonHeight = bHeight; column++; if(column == 5) { line++; column = 0; } GuiButton button = new ButtonCard(id, sf, i, j, "", itCard, trX, trY, bWidth, bHeight, this); this.buttonList.add(button); id++; } allCardButtons = id; } public void initDeckCards() { int line = 0; int column = 0; int id = allCardButtons; for(Card itCard : deck) { ResourceLocation resource = itCard.getResource(); float trX = (float)width-(float)width/2.45F +(float)(column* width/17); float trY = (float)height/3.1F +(float)(line* width/13)+(float)this.scroll2; int i = (int)trX; int j = (int)trY; float sf = (float)width/256F /20F; int rF = res.getScaleFactor(); float fWidth = sf * 256F; float fHeight = sf * 373F; int bWidth = (int)fWidth; int bHeight = (int)fHeight; this.buttonHeight = bHeight; column++; if(column == 5) { line++; column = 0; } GuiButton button = new ButtonCard(id, sf, i, j, "", itCard, trX, trY, bWidth, bHeight, this); this.buttonList.add(button); id++; } allCardButtons = id; } public void initControls() { initButtonUp(); initButtonDown(); initDeckUp(); initDeckDown(); } //init controls public void initButtonUp() { ResourceLocation resource = new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonUp.png"); float sF = (float)width/33F/20; int posX = width/4 + width/27; int posY = height/8; float fWidth = sF * 33F; float fHeight = sF * 19F; int bWidth = (int)fWidth; int bHeight = (int)fHeight; ButtonControl cardUp = new ButtonControl(allCardButtons+1, posX, posY, bWidth, bHeight, "", resource); cardUp.setScale(sF); cardUp.setTextureScale(33, 19); cardUp.setTr((float)posX, (float)posY); this.cardUp = cardUp; this.buttonList.add(this.cardUp); } public void initButtonDown() { ResourceLocation resource = new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonDown.png"); float sF = (float)width/33F/20; int posX = width/4 + width/27; int posY = height-height/16; float fWidth = sF * 33F; float fHeight = sF * 19F; int bWidth = (int)fWidth; int bHeight = (int)fHeight; ButtonControl cardDown = new ButtonControl(allCardButtons+2, posX, posY, bWidth, bHeight, "", resource); cardDown.setScale(sF); cardDown.setTextureScale(33, 19); cardDown.setTr((float)posX, (float)posY); this.cardDown = cardDown; this.buttonList.add(this.cardDown); } public void initDeckUp() { ResourceLocation resource = new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonUp.png"); float sF = (float)width/33F/20; int posX = width-width/4; int posY = height/4; float fWidth = sF * 33F; float fHeight = sF * 19F; int bWidth = (int)fWidth; int bHeight = (int)fHeight; ButtonControl cardUp = new ButtonControl(allCardButtons+3, posX, posY, bWidth, bHeight, "", resource); cardUp.setScale(sF); cardUp.setTextureScale(33, 19); cardUp.setTr((float)posX, (float)posY); this.deckUp = cardUp; this.buttonList.add(this.deckUp); } public void initDeckDown() { ResourceLocation resource = new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonDown.png"); float sF = (float)width/33F/20; int posX = width-width/4; int posY = height-height/16; float fWidth = sF * 33F; float fHeight = sF * 19F; int bWidth = (int)fWidth; int bHeight = (int)fHeight; ButtonControl cardDown = new ButtonControl(allCardButtons+4, posX, posY, bWidth, bHeight, "", resource); cardDown.setScale(sF); cardDown.setTextureScale(33, 19); cardDown.setTr((float)posX, (float)posY); this.deckDown = cardDown; this.buttonList.add(this.deckDown); } public void updateControlResources(int mouseX, int mouseY) { cardUp.setMouse(mouseX, mouseY); cardDown.setMouse(mouseX, mouseY); deckUp.setMouse(mouseX, mouseY); deckDown.setMouse(mouseX, mouseY); if(cardUp.hoverState == 1)cardUp.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonup2.png")); else cardUp.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonup.png")); if(cardDown.hoverState == 1)cardDown.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttondown2.png")); else cardDown.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttondown.png")); if(deckUp.hoverState == 1)deckUp.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonup2.png")); else deckUp.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttonup.png")); if(deckDown.hoverState == 1)deckDown.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttondown2.png")); else deckDown.setResource(new ResourceLocation(DuelMonsters.MODID, "textures/textures/gui/buttondown.png")); } } And this is the Gui I am opening: package armamenthaki.duelmonsters.gui; import java.util.ArrayList; import armamenthaki.duelmonsters.duel.Card; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; public class GuiCardDisplay extends GuiScreen { private ResourceLocation resource; private GuiScreen guiIn; private Card card; public GuiCardDisplay(GuiScreen gui, Card card) { this.card = card; this.resource = card.getResource(); this.guiIn = gui; } public GuiCardDisplay(GuiScreen gui, ArrayList<Card> cards, int id) { this.card = cards.get(id); this.resource = card.getResource(); this.guiIn = gui; } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { mc.renderEngine.bindTexture(resource); GlStateManager.translate((float)this.width/4, (float)this.height/3, 1.0); float sf = (float)this.width/256F/4F; GlStateManager.scale(sf, sf, 1.0F); this.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 256, 373, 256, 373); } @Override public void initGui() { GuiButton button = new GuiButton(0, 0, 0, this.width, this.height, ""); this.buttonList.add(button); } public void actionPerformed(GuiButton button) { if(button.id == 0)mc.displayGuiScreen(this.guiIn); } } I hope it isn't to hard to understand, thank you for your help.
  25. thanks, I didn't know the zLevels Default was 0, so that in the Translation of the Buttons i used 1.0 as a modifier. now it works.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.