Jump to content

feldim2425

Members
  • Posts

    19
  • Joined

  • Last visited

Converted

  • Gender
    Male

feldim2425's Achievements

Tree Puncher

Tree Puncher (2/8)

4

Reputation

  1. I don't know if thats a good solution but the way I do it, I give the Y argument a negative number when calling the player.openGui(...) so the Y value in getClientGuiElement() is also negative. (TE's & Blocks should not exist at a negative Y Coordinate) So the X can be set to entity.getEntityId(). And you can get the Entity Object back by calling world.getEntityByID(x) @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(y==-10 && ID == 0){ Entity entity = world.getEntityByID(x); if(entity!=null){ return new EntityGuiContainer(entity) } } return null; } Open with: player.openGui(Mod.instance, 0, world, entity.getEntityId(), -10 , 0);
  2. No the Capabilities are for stuff thats similar to other tile entities and stuff that should be compatible with other mods (like Inventory, FluidTank , ...) Normal data (as you sayed some integer and booleans) are still stored in NBT with the writeToNBT() and readFromNBT() method
  3. Let the BlockEnergyGeneratorCoal class extend BlockContainer and not Block.
  4. I forgot to say, that I want use dynamic colors. If this is possible EDIT: Forgot that it's possible to set a color overlay
  5. Hi. I want to render a gradient rectangle in the world but it doesn't render the gradient. render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); render.pos(length, -beamWidth, beamWidth).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); tes.draw(); How can I render a gradient rectangle in the world with the Tessellator and the WorldRenderer?
  6. You also have a problem in the switch-case. You have to check if the id from the getClientGuiObject (id is the first integer value) is equal to your GUI id (you choose 6) switch(id){ case 6: //6 is the GUI id. return new GuiJournalThree(); } return null;
  7. In my code the init function shuold get called in the preInit function in the Main Mod class or in the common proxy.
  8. Does the id is equal to the id from the switch-case in the getClientGuiElement() function? Have you registred the Gui handler? Maybe you also need to check the side, because the Server element is null.
  9. Something like this should work: public class GuiHandler implements IGuiHandler{ public static void init(){ NetworkRegistry.INSTANCE.registerGuiHandler(<Mod instance>, new GuiHandler()); } @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch(id){ case 0: return new GuiJournalThree(); } return null; } }
  10. If nothing works, you can try a GUIHandler and open the gui with player.openGui(<Mod instance>, <GUI-ID>, world, 0, 0, 0); But this is also Server Side. EDIT: Can you post the last crash report / log file?
  11. onItemRightClick() is also called on the ServerSide. On the Server Side Minecraft.getMinecraft().displayGuiScreen() doesn't work. Try: if(world.isRemote){ Minecraft.getMinecraft().displayGuiScreen(new GuiJournalThree()); } return itemstack;
  12. I found the problem it seems like withProperty() for the IUnlistedProperty doesn't change the state, it just returns the new state. For everyone who has the same problem, here is the new method: public IBlockState getExtendedState(IBlockState state) { checkConnections(); return ((IExtendedBlockState) state).withProperty(PROPERTY_CONNECTION, this.connections).withProperty(PROPERTY_TYPE, this.type); } I also use a unlisted Byte property, where the first 6 bits are the 6 sides of the block.
  13. I have a MCMultipart cable. I can write the 6 directions to the Extendet Blockstate without problem, but if I get the Property Value, the function returns null. Cable Class public class PartRfCable extends Multipart implements IOccludingPart, ISlottedPart, ITickable, IEnergyHandler { public static IUnlistedProperty<Boolean>[] sides = PropertyCableConnection.getPropertyList(); public static IProperty<EnumCableType> cableType = new EnumCableType.PropertyCableType(); private HashMap<EnumFacing, Boolean> connections = new HashMap<>(); private boolean updateDone; private EnumCableType type; public PartRfCable(EnumCableType type){ super(); this.type=type; } public PartRfCable(){ super(); } @Override public void addOcclusionBoxes(List<AxisAlignedBB> list) { list.add(AxisAlignedBB.fromBounds(0,0,0,1,1,1)); } @Override public void addSelectionBoxes(List<AxisAlignedBB> list) { list.add(AxisAlignedBB.fromBounds(4F/16F,4F/16F,4F/16F,12F/16F,12F/16F,12F/16F)); } @Override public void addCollisionBoxes(AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) { list.add(AxisAlignedBB.fromBounds(0,0,0,1,1,1)); } @Override public void update() { if(!updateDone){ //onLoaded() gets called before other TE's are loaded => Crash checkConnections(); updateDone =true; } } public String getModelPath() { return RfAdditions.MOD_ID+":rfcable"; } public Material getMaterial() { return Material.iron; } public float getHardness(PartMOP hit) { return 3.0F; } public BlockState createBlockState() { return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[]{cableType} , sides); } @Override public int receiveEnergy(EnumFacing facing, int maxReceive, boolean simulate) { return 0; } @Override public int extractEnergy(EnumFacing facing, int maxExtract, boolean simulate) { return 0; } @Override public int getEnergyStored(EnumFacing facing) { return 0; } @Override public int getMaxEnergyStored(EnumFacing facing) { return 0; } @Override public boolean canConnectEnergy(EnumFacing facing) { return false; } private boolean canConnect(TileEntity handler, EnumFacing face){ if(handler == null) return false; return true; /*else if(handler instanceof IMultipartContainer){ IMultipartContainer container = (IMultipartContainer) handler; Collection<? extends IMultipart> parts = container.getParts(); for (IMultipart p : parts){ if(p instanceof IEnergyConnection) return ((IEnergyConnection)p).canConnectEnergy(face.getOpposite()); } } else if(handler instanceof IEnergyConnection){ return ((IEnergyConnection)handler).canConnectEnergy(face.getOpposite()); }*/ //return false; } public IBlockState getExtendedState(IBlockState state) { for(EnumFacing f : EnumFacing.VALUES){ if(this.getContainer() == null || this.getPos()==null || this.getWorld()==null || sides[f.ordinal()]==null) continue; BlockPos tilepos = getPos().add(f.getFrontOffsetX(), f.getFrontOffsetY(), f.getFrontOffsetY()); ((IExtendedBlockState)state).withProperty(sides[f.ordinal()], true); } if(type!=null){ state.withProperty(cableType,type); } else { state.withProperty(cableType,EnumCableType.CONDUCTIVE_REDSTONE); } Collection<IUnlistedProperty<?>> test = ((IExtendedBlockState) state).getUnlistedNames(); for(IUnlistedProperty<?> t : test){ System.out.println(t.getName()+ " : "+((IExtendedBlockState)state).getValue(t)); // getValue is null } return state; } private void checkConnections(){ connections.clear(); IMultipartContainer container = this.getContainer(); for(EnumFacing facing : EnumFacing.VALUES) { BlockPos changed = container.getPosIn().add(facing.getFrontOffsetX(), facing.getFrontOffsetY(), facing.getFrontOffsetY()); connections.put(facing, canConnect(container.getWorldIn().getTileEntity(changed), facing)); } } public void onNeighborBlockChange(Block block) { super.onNeighborBlockChange(block); checkConnections(); if(this.getContainer() != null && this.getPos()!=null){ getWorld().markBlockForUpdate(getPos()); } } public void onAdded() { super.onAdded(); checkConnections(); } @Override public EnumSet<PartSlot> getSlotMask() { return EnumSet.of(PartSlot.CENTER); } } Property Class public class PropertyCableConnection{ public static IUnlistedProperty<Boolean>[] getPropertyList(){ IUnlistedProperty[] p = new IUnlistedProperty[EnumFacing.VALUES.length]; int i=0; for(EnumFacing f: EnumFacing.VALUES){ p[i]= Properties.toUnlisted(PropertyBool.create(f.getName())); i++; } return p; } public static boolean getSide(EnumFacing face, IBlockState state){ if(!(state instanceof IExtendedBlockState)) return false; Collection<IUnlistedProperty<?>> props = ((IExtendedBlockState)state).getUnlistedNames(); IUnlistedProperty<?> found = null; for (IUnlistedProperty<?> p : props){ if(p.getName() == face.getName() && p.getType()==Boolean.class) found=p; } if(found==null) return false; return ((IExtendedBlockState)state).getValue((IUnlistedProperty<Boolean>) found); // NullPointerException } }
  14. Is there a way in 1.8 to render a item in a item? Like the /dev/null from ExtraUtilities.
  15. Hi. I want to add a additional drop to a Minecart but I can't access the class (Vanilla minecart). Is there an event that triggers on entity or minecart death?
×
×
  • Create New...

Important Information

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