Jump to content

MrRiegel

Members
  • Posts

    47
  • Joined

  • Last visited

Everything posted by MrRiegel

  1. Where do you call ModItems.registerRenders()?
  2. Is it really necessary to create a new capabiliy if I want to add an integer to the player? What about this: player.getEntityData().setInteger("blabla", 1111); ?
  3. Hi, I'm trying to move entities from one dimension to another. The task sounds quite simple. The parameters should look like this: void teleport(Entity entity, int dimension, BlockPos pos) code: Teleporter tele = new PortalTeleporter((WorldServer) target.getWorld(worldObj), tar.selfLanding); if (entity instanceof EntityPlayerMP) { worldObj.getMinecraftServer().getPlayerList().transferPlayerToDimension((EntityPlayerMP) entity, target.getDimension(), tele); } else { worldObj.getMinecraftServer().getPlayerList().transferEntityToWorld(entity, entity.worldObj.provider.getDimension(), (WorldServer) entity.worldObj, (WorldServer) target.getWorld(worldObj), tele); } public class PortalTeleporter extends Teleporter { BlockPos pos; WorldServer world; public PortalTeleporter(WorldServer worldIn, BlockPos pos) { super(worldIn); this.world = worldIn; this.pos = pos; } @Override public void placeInPortal(Entity entityIn, float rotationYaw) { this.world.getBlockState(pos); entityIn.setPosition(pos.getX() + .5, pos.getY() + .05, pos.getZ() + .5); } } It works fine for players but other entities are not working correctly. Sometimes they vanish or duplicate. Some warnings in the logs: [01:56:31] [server thread/WARN]: Wrong location! (12, 10) should be (5, 0), EntityItem['item.item.fireball'/3960, l='New World', x=194,51, y=64,00, z=174,04] [01:56:31] [server thread/WARN]: Tried to add entity Item but it was marked as removed already [01:56:31] [server thread/WARN]: Keeping entity Item that already exists with UUID d27bbf73-764b-4f91-9877-c6679b958684 Is there a better solution for teleporting non-player entities (e.g. mobs,animals,items)? thx
  4. Sorry, that isn't the solution I was looking for. Maybe it will solve the problem for me but not the ones that will use the mod. And even if it works the start still lasts ~5 min. Why do a few blockstate files suck up 2 GB memory? Pressure Pipes and NeoTech use very similar blockstate files for their cables and they don't have that kind of problem. What am I doing wrong?
  5. Hi, I created some cable blocks and I want to render them with json files. But starting MC takes an eternity and in the end it crashs with an OutOfMemoryError. Thats the blockstate file and I have 6 (similiar) more of them: The models look like that just in case the block class Thanks for your help
  6. hey guys here is my problem: Is there a way to make the light more smooth? GlStateManager.pushMatrix(); GlStateManager.enableRescaleNormal(); GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); GlStateManager.pushMatrix(); GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.disableStandardItemLighting(); // RenderHelper.enableStandardItemLighting(); model.render(te); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  7. hey guys here is my problem: Is there a way to make the light more smooth? GlStateManager.pushMatrix(); GlStateManager.enableRescaleNormal(); GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); GlStateManager.pushMatrix(); GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.disableStandardItemLighting(); // RenderHelper.enableStandardItemLighting(); model.render(te); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  8. I guess you can understand the problem. Running './gradlew eclipse' fix this, but only for this day. On the next day the problem is back. That's annoying. Any ideas? Thanks
  9. It's not MY texture. As you can see in the code I want to render an itemstack in the GUI of an automatic crafter. the itemstack is the crafting result.
  10. How can I render blocks and items semi-transparent? I should look like this: (the right one) this.bindTexture(TextureMap.locationBlocksTexture); BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); World world = te.getWorld(); BlockPos blockpos = te.getPos(); IBlockState iblockstate = te.getCover().getStateFromMeta(te.getCoverMeta()); GlStateManager.pushMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.translate((float) x, (float) y, (float) z); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); int i = blockpos.getX(); int j = blockpos.getY(); int k = blockpos.getZ(); worldrenderer.setTranslation(((-i)), (-j), ((-k))); worldrenderer.color(1F, 1F, 1F, 1F); IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(iblockstate, world, blockpos); blockrendererdispatcher.getBlockModelRenderer().renderModel(world, ibakedmodel, iblockstate, blockpos, worldrenderer, true); worldrenderer.setTranslation(0.0D, 0.0D, 0.0D); tessellator.draw(); RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.disableDepth(); int j1 = 150; int k1 = 35; GlStateManager.colorMask(true, true, true, false); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.color(1f, 1f, 1f, 1f); ItemStack result = CraftingManager.getInstance().findMatchingRecipe(((ContainerCrafter) inventorySlots).crafter.getMatrix(), mc.theWorld); mc.getRenderItem().renderItemAndEffectIntoGUI(result, j1, k1); RenderHelper.disableStandardItemLighting(); GlStateManager.colorMask(true, true, true, true); GlStateManager.enableLighting(); GlStateManager.enableDepth(); GlStateManager.popMatrix();
  11. @Choonster I did, but I don't get it. The AE code is pretty complicated. @7 Thanks for your hints. A cable should not have a network by itself. A controller is necessary. And of course there's only one controller per network. If I connect 2 networks, one of the controllers drops. current method to fill the list private void addCables(final BlockPos pos) { for (BlockPos bl : getNeighbors(pos)) { if (worldObj.getTileEntity(bl) instanceof TileMaster && !bl.equals(this.pos) && worldObj.getChunkFromBlockCoords(bl) != null && worldObj.getChunkFromBlockCoords(bl).isLoaded()) { worldObj.getBlockState(bl).getBlock().dropBlockAsItem(worldObj, bl, worldObj.getBlockState(bl), 0); worldObj.setBlockToAir(bl); worldObj.removeTileEntity(bl); continue; } if (worldObj.getTileEntity(bl) instanceof IConnectable && !connectables.contains(bl) && worldObj.getChunkFromBlockCoords(bl).isLoaded()) { connectables.add(bl); ((IConnectable) worldObj.getTileEntity(bl)).setMaster(this.pos); addCables(bl); } } }
  12. Hey guys, I created a network with cables and one cable controller (similiar to AE). The list of blockPos of the cables is a field in the cable controller. Every time a cable is placed or removed I need to refresh the entire list (recursive). Problem: If the network has many cables (>500), a refresh decreases the fps. How can I prevent this? AE doesn't have this problem. Can I increases the fps by refreshing the list in another thread?
  13. Hi, I was looking for library mods for 1.8.9 that offers useful methods and classes. for example GUI components, InventoryHelper, RenderHelper or other neat utilities. I could write my own methods and classes but I don't want to overstock the market with another Library Mod and other libraries may be better than mine could ever be. MalisisCore looks pretty useful. CoFHLib too, but it's not available for 1.8.9 yet. Any ideas? thx
  14. Is it possible to make only one json file for any fluid? because the number of fluids is arbitrary. I change the color of the fluids in a config file. And another question: As long as the fluids spreads the fps decrease by 10-20. With water and lava fps is stable. Any idea why? fluids.json { "forge_marker": 1, "defaults": { "model": "forge:fluid" }, "variants": { "normal": [ { "custom": { "fluid": "what name here ?" } } ] } } ModFluids.java public class ModFluids { public static final Map<Integer, Fluid> fluids = Maps.newHashMap(); public final static Map<Integer, CustomBlockFluid> blocks = Maps .newHashMap(); public static void registerFluids(List<CustomFluid> list) { for (int i = 0; i < list.size(); i++) { CustomFluid fluid = list.get(i); registerFluid(fluid, i); } } private static void registerFluid(CustomFluid f, int index) { boolean useOwnFluid = FluidRegistry.registerFluid(f.toFluid()); if (useOwnFluid) { fluids.put(index, FluidRegistry.getFluid(f.name)); registerFluidBlock(f, index); } } private static void registerFluidBlock(CustomFluid fluid, int index) { CustomBlockFluid block = new CustomBlockFluid(fluid); block.setRegistryName("fluid." + block.getFluid().getName()); block.setUnlocalizedName(CustomFluids.MODID + ":" + block.getFluid().getUnlocalizedName()); block.setCreativeTab(CreativeTab.tab1); blocks.put(index, block); GameRegistry.registerBlock(blocks.get(index)); FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(fluid.name)); } } ClientProxy.java public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent event) throws IOException { super.preInit(event); registerRenderers(); for (Entry<Integer, Fluid> e:ModFluids.fluids.entrySet()) { Fluid f=e.getValue(); Item fluid = Item.getItemFromBlock(f.getBlock()); ModelBakery.registerItemVariants(fluid); final ModelResourceLocation fluidLocation = new ModelResourceLocation( CustomFluids.MODID + ":fluid"); ModelLoader.setCustomMeshDefinition(fluid, new ItemMeshDefinition() { public ModelResourceLocation getModelLocation( ItemStack stack) { return fluidLocation; } }); ModelLoader.setCustomStateMapper(f.getBlock(), new StateMapperBase() { protected ModelResourceLocation getModelResourceLocation( IBlockState state) { return fluidLocation; } }); } } @Override public void init(FMLInitializationEvent event) { super.init(event); registerItemModels(); } @Override public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } public void registerItemModels() { } public void registerRenderers() { } } CustomFluid.java public class CustomFluid { String name; String displayName; int luminosity; int density = 1000; int temperature = 300; int viscosity = 1000; boolean gas; List<String> biomes; List<Effect> effects; boolean flammable; boolean fireSource; String material; boolean generate; int lakeSize; int chunkChance; int color = 0x6495ED; Design design = Design.WATER; enum Design { WATER, LAVA; ResourceLocation getStill() { if (this == WATER) return new ResourceLocation(CustomFluids.MODID + ":fluid/liquid"); else if (this == LAVA) return new ResourceLocation(CustomFluids.MODID + ":fluid/molten_metal"); return new ResourceLocation(CustomFluids.MODID + ":fluid/liquid"); } ResourceLocation getFlowing() { if (this == WATER) return new ResourceLocation(CustomFluids.MODID + ":fluid/liquid_flow"); else if (this == LAVA) return new ResourceLocation(CustomFluids.MODID + ":fluid/molten_metal_flow"); return new ResourceLocation(CustomFluids.MODID + ":fluid/liquid_flow"); } } public CustomFluid(String name, String displayName, int luminosity, int density, int temperature, int viscosity, boolean gas, List<String> biomes, List<Effect> effects, boolean flammable, boolean fireSource, String material, boolean generate, int lakeSize, int chunkChance, int color, Design design) { this.name = name; this.displayName = displayName; this.luminosity = luminosity; this.density = density; this.temperature = temperature; this.viscosity = viscosity; this.gas = gas; this.biomes = biomes; this.effects = effects; this.flammable = flammable; this.fireSource = fireSource; this.material = material; this.generate = generate; this.lakeSize = lakeSize; this.chunkChance = chunkChance; this.color = color; this.design = design; } public Fluid toFluid() { return new Fluid(name, null, null) { @Override public String getLocalizedName(FluidStack stack) { return displayName; } @Override public int getColor() { int c = color; if (((c >> 24) & 0xFF) == 0) { c |= 0xFF << 24; } return c; } @Override public ResourceLocation getStill() { return design.getStill(); } @Override public ResourceLocation getFlowing() { return design.getFlowing(); } }.setLuminosity(luminosity).setDensity(density) .setTemperature(temperature).setViscosity(viscosity) .setGaseous(gas); } }
  15. @diesieben public class SyncMessage implements IMessage, IMessageHandler<SyncMessage, IMessage> { List<BlockPos> lis; public SyncMessage() { } public SyncMessage(EntityPlayer player) { ItemFinder.lis = new ArrayList<BlockPos>(); int range = ItemFinder.range; for (int i = -range; i <= range; i++) for (int j = -range; j <= range; j++) for (int k = -range; k <= range; k++) { BlockPos pos = new BlockPos(i + player.posX, j + player.posY, k + player.posZ); if (player.worldObj.getTileEntity(pos) instanceof IInventory) { IInventory inv = (IInventory) player.worldObj .getTileEntity(pos); for (int ii = 0; ii < inv.getSizeInventory(); ii++) { if (inv.getStackInSlot(ii) != null && inv.getStackInSlot(ii).isItemEqual( player.getHeldItem())) { ItemFinder.lis.add(pos); break; } } } } lis = new ArrayList<BlockPos>(ItemFinder.lis); } @Override public IMessage onMessage(final SyncMessage message, MessageContext ctx) { IThreadListener mainThread = Minecraft.getMinecraft(); mainThread.addScheduledTask(new Runnable() { @Override public void run() { ItemFinder.lis = new ArrayList<BlockPos>(message.lis); } }); return null; } @Override public void fromBytes(ByteBuf buf) { this.lis = new Gson().fromJson(ByteBufUtils.readUTF8String(buf), new TypeToken<List<BlockPos>>() { }.getType()); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, new Gson().toJson(this.lis)); } } @failender thanks, I'm gonna try this
  16. Actually it is a list of BlockPos. The result is the same. Every BlockPos is 0,0,0
  17. hi, I need to send a BlockPos from server to client. I use SimpleNetworkWrapper. //test BlockPos zz = new BlockPos(3, 435, 12); @Override public void fromBytes(ByteBuf buf) { this.zz = new Gson().fromJson(ByteBufUtils.readUTF8String(buf), new TypeToken<BlockPos>() { }.getType()); System.out.println("from: " + this.zz); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, new Gson().toJson(this.zz)); System.out.println("to: " + this.zz); } It works fine on client. [19:42:11] [server thread/INFO] [sTDOUT]: [mrriegel.ifinder.SyncMessage:toBytes:82]: to: BlockPos{x=3, y=435, z=12} [19:42:11] [Netty Local Client IO #0/INFO] [sTDOUT]: [mrriegel.ifinder.SyncMessage:fromBytes:75]: from: BlockPos{x=3, y=435, z=12} But on server it doesn't work. [19:48:52] [server thread/INFO] [sTDOUT]: [mrriegel.ifinder.SyncMessage:toBytes:82]: to: BlockPos{x=3, y=435, z=12} [19:48:52] [Netty Epoll Client IO #1/INFO] [sTDOUT]: [mrriegel.ifinder.SyncMessage:fromBytes:75]: from: BlockPos{x=0, y=0, z=0} I hope someone can help
  18. Is there any way to get the items in a chest (or other tile entities) on the client WITHOUT sending packets? the mod should by client side only. thanks
  19. Hi, the title says enough. I want to make a scrollable guicontainer (like AE terminal), but that NEI feature is disruptive.
  20. solved, by removing every worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); I don't know why this worked.
  21. hey, I made a TE which processes 2 items into 2 other items. Sometimes, only while the processing is true, when I took an itemstack from a TE slot, on the client the itemstack is still in the machine. normal behaviour: bad behaviour: TE: public class TileElectrolyzer extends TileEntity implements ISidedInventory { public static final int INV_SIZE = 5; public static String tagName = "TileEle"; private ItemStack[] inv; private int puffer, process; private boolean processing; ItemStack o1, o2; public TileElectrolyzer() { super(); inv = new ItemStack[iNV_SIZE]; } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); System.out.println("read_before: " + inv[4]); NBTTagList invList = tag .getTagList(tagName, Constants.NBT.TAG_COMPOUND); for (int i = 0; i < invList.tagCount(); i++) { NBTTagCompound stackTag = invList.getCompoundTagAt(i); int slot = stackTag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(stackTag); } } System.out.println("read_after: " + inv[4]); puffer = tag.getInteger("puffer"); processing = tag.getBoolean("processing"); NBTTagCompound st1 = (NBTTagCompound) tag.getTag("o1"); o1 = ItemStack.loadItemStackFromNBT(st1); NBTTagCompound st2 = (NBTTagCompound) tag.getTag("o2"); o2 = ItemStack.loadItemStackFromNBT(st2); } @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); System.out.println("write_before: " + inv[4]); NBTTagList invList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { if (inv[i] != null) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); inv[i].writeToNBT(stackTag); invList.appendTag(stackTag); } } tag.setInteger("puffer", puffer); tag.setBoolean("processing", processing); NBTTagCompound st1 = new NBTTagCompound(); if (o1 != null) o1.writeToNBT(st1); tag.setTag("o1", st1); NBTTagCompound st2 = new NBTTagCompound(); if (o2 != null) o2.writeToNBT(st2); tag.setTag("o2", st2); tag.setTag(tagName, invList); System.out.println("write_after: " + inv[4]); } @Override public Packet getDescriptionPacket() { NBTTagCompound syncData = new NBTTagCompound(); this.writeToNBT(syncData); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, syncData); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); } @Override public ItemStack decrStackSize(int slot, int size) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= size) { setInventorySlotContents(slot, null); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return stack; } else { stack = stack.splitStack(size); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return stack; } } else { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return null; } } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if (slot == 2 || slot == 3) return false; if (slot == 4) if (stack.getItem().equals(Items.redstone) || stack.getItem().equals( Item.getItemFromBlock(Blocks.redstone_block))) return true; else return false; return true; } @Override public int[] getAccessibleSlotsFromSide(int side) { return side == 1 ? new int[] { 0, 1 } : side != 0 ? new int[] { 4 } : new int[] { 2, 3 }; } @Override public boolean canInsertItem(int slot, ItemStack stack, int side) { if ((slot == 0 || slot == 1) && side == 1) return true; if (slot == 4 && side != 0 && side != 1) return true; return false; } @Override public boolean canExtractItem(int slot, ItemStack stack, int side) { if (side == 0 && (slot == 2 || slot == 3)) return true; else return false; } @Override public void updateEntity() { super.updateEntity(); if (worldObj.isRemote) return; //fill fuel ItemStack fuel = getStackInSlot(4); if (fuel != null && worldObj.getTotalWorldTime() % 6 == 0) { if (fuel.getItem().equals(Items.redstone) && puffer <= 45 - 3) { puffer += 3; --fuel.stackSize; if (fuel.stackSize <= 0) setInventorySlotContents(4, null); else setInventorySlotContents(4, fuel.copy()); } else if (fuel.getItem().equals( Item.getItemFromBlock(Blocks.redstone_block)) && puffer <= 45 - 36) { puffer += 36; --fuel.stackSize; if (fuel.stackSize <= 0) setInventorySlotContents(4, null); else setInventorySlotContents(4, fuel.copy()); } } //check for recipe if (!processing && getStackInSlot(0) != null && getStackInSlot(1) != null && puffer >= 6) { boolean match = false; for (ElectrolyzerRecipe r : ElectrolyzerRecipes.lis) { if (r.matches(worldObj, this) && !RiegelUtils.isStackEqual(getStackInSlot(0), getStackInSlot(1))) { boolean zwei = getStackInSlot(2) == null && getStackInSlot(3) == null; boolean eins; try { eins = RiegelUtils.isStackEqual(r.getOutput1(), getStackInSlot(2)) && RiegelUtils.isStackEqual(r.getOutput2(), getStackInSlot(3)) && getStackInSlot(2).stackSize < getStackInSlot( 2).getMaxStackSize() && getStackInSlot(3).stackSize < getStackInSlot( 3).getMaxStackSize(); } catch (NullPointerException e) { System.out.println(e.getMessage()); eins = false; } if (eins || zwei) { match = true; o1 = r.getOutput1().copy(); o2 = r.getOutput2().copy(); break; } } } if (match) { RiegelUtils.decr(this, 0); RiegelUtils.decr(this, 1); puffer -= 6; processing = true; } } //process if (processing && worldObj.getTotalWorldTime() % 20 / 3 == 0) { if (process < 24) process++; else { process = 0; processing = false; RiegelUtils.incr(this, 2, o1); RiegelUtils.incr(this, 3, o2); o1 = null; o2 = null; } worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); //updating progressbar PacketHandler.INSTANCE.sendToDimension(new PacketUpdate(xCoord, yCoord, zCoord, process, getStackInSlot(0) == null, getStackInSlot(1) == null, getStackInSlot(4) == null), worldObj.provider.dimensionId); } } }
  22. you cannot edit net.minecraft.client.renderer.RenderBlocks
  23. BlockFire has rendertype 3. If I made my fire having rendertype 3 too without extending Blockfire, mc throws an classcastexception. case 3: return this.renderBlockFire((BlockFire)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; I could make renderBlockModFire() for my own fire, but I don't know how to register this
  24. I their a way to make a custom fire not dying when hit by flowing water? I created a fireblock which extends Block, copy the methods from BlockFire and set the Material to gourd. That worked, but the rendering was different.
×
×
  • Create New...

Important Information

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