
493msi
Members-
Posts
14 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
493msi's Achievements

Tree Puncher (2/8)
0
Reputation
-
I didn't intend to make the overlay fully bright, but it looks cool, so I will keep it like that: OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); Had to look at how the lightmap works, that's the reason I didn't understand it before.
-
So, update. I was looking for a solution somewhere else and I found a solution for the dark shading: int li = te.getWorld().getCombinedLight(te.getPos(), 15728640); int u = li % 65536; int v = li / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, u, v); Not sure what it does, because it is not documented. There is one problem, it ignores block lighting and uses only sky lighting. My new render code: private static final int GL11_GL_QUADS = 0x7; protected final ResourceLocation frontTex = new ResourceLocation(SECore.MOD_ID, "textures/blocks/machines/overlay.png"); public void renderTileEntityAt(TileEntityMachinePowered te, double x, double y, double z, float partialTicks, int destroyStage) { GlStateManager.pushMatrix(); GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5); GlStateManager.disableLighting(); GlStateManager.color(1, 1, 1, 1); GlStateManager.disableCull(); int li = te.getWorld().getCombinedLight(te.getPos(), 15728640); int u = li % 65536; int v = li / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, u, v); Tessellator tessellator = Tessellator.getInstance(); Minecraft.getMinecraft().getTextureManager().bindTexture(frontTex); if(te.connectionType[EnumFacing.NORTH.getIndex()] != EnumConnectionType.DEFAULT) { storeSide(tessellator.getBuffer(), te.connectionType[EnumFacing.NORTH.getIndex()].getFloatUVs()); tessellator.draw(); } GlStateManager.rotate(90, 0, 1, 0); if(te.connectionType[EnumFacing.WEST.getIndex()] != EnumConnectionType.DEFAULT) { storeSide(tessellator.getBuffer(), te.connectionType[EnumFacing.WEST.getIndex()].getFloatUVs()); tessellator.draw(); } GlStateManager.rotate(90, 0, 1, 0); if(te.connectionType[EnumFacing.SOUTH.getIndex()] != EnumConnectionType.DEFAULT) { storeSide(tessellator.getBuffer(), te.connectionType[EnumFacing.SOUTH.getIndex()].getFloatUVs()); tessellator.draw(); } GlStateManager.rotate(90, 0, 1, 0); if(te.connectionType[EnumFacing.EAST.getIndex()] != EnumConnectionType.DEFAULT) { storeSide(tessellator.getBuffer(), te.connectionType[EnumFacing.EAST.getIndex()].getFloatUVs()); tessellator.draw(); } GlStateManager.rotate(90, 0, 1, 0); GlStateManager.rotate(90, 1, 0, 0); if(te.connectionType[EnumFacing.UP.getIndex()] != EnumConnectionType.DEFAULT) { storeSide(tessellator.getBuffer(), te.connectionType[EnumFacing.UP.getIndex()].getFloatUVs()); tessellator.draw(); } GlStateManager.rotate(180, 1, 0, 0); if(te.connectionType[EnumFacing.DOWN.getIndex()] != EnumConnectionType.DEFAULT) { storeSide(tessellator.getBuffer(), te.connectionType[EnumFacing.DOWN.getIndex()].getFloatUVs()); tessellator.draw(); } GlStateManager.popMatrix(); } private VertexBuffer storeSide(VertexBuffer buffer, float[] uvs) { buffer.begin(GL11_GL_QUADS, DefaultVertexFormats.POSITION_TEX); double smallShift = .01; buffer.pos(-0.5, -0.5, -0.5 - smallShift).tex(uvs[0], uvs[3]).endVertex(); buffer.pos(-0.5, 0.5, -0.5 - smallShift).tex(uvs[0], uvs[1]).endVertex(); buffer.pos(0.5, 0.5, -0.5 - smallShift).tex(uvs[2], uvs[1]).endVertex(); buffer.pos(0.5, -0.5, -0.5 - smallShift).tex(uvs[2], uvs[3]).endVertex(); return buffer; }
-
That was a temporary solution. Otherwise I am very tidy with my code. I forgot to explain what I am trying to achieve. I have a full, opaque block and I want to draw overlay on each side similar to EnderIO reconfigurable sides. I already rewrote the system again to render the original block normally (using JSON) and then draw the overlay quads with TESR. It works except for the lighting problem. Anyway, it's 11 44 PM in my country, so I will check other options you suggested and post my new render code tommorrow.
-
So I rewrote most of the model to TESR and it works fine, except the entire block is very very dark. Like white -> dark gray. I often work with LWJGL, but now I am completely lost. private static final int GL11_GL_QUADS = 0x7; public void renderTileEntityAt(TileEntityMachinePowered te, double x, double y, double z, float partialTicks, int destroyStage) { GlStateManager.pushMatrix(); GlStateManager.enableLighting(); GlStateManager.enableDepth(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5); Tessellator tessellator = Tessellator.getInstance(); EnumFacing blockFacing = (EnumFacing) te.getWorld().getBlockState(te.getPos()).getProperties().get(BlockMachineGeneric.FACING); Minecraft.getMinecraft().getTextureManager().bindTexture(((BlockMachineSided) te.getBlockType()).getTextureOnSide(EnumFacing.NORTH, blockFacing)); drawSide(tessellator.getBuffer()); tessellator.draw(); GlStateManager.rotate(90, 0, 1, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(((BlockMachineSided) te.getBlockType()).getTextureOnSide(EnumFacing.WEST, blockFacing)); drawSide(tessellator.getBuffer()); tessellator.draw(); GlStateManager.rotate(90, 0, 1, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(((BlockMachineSided) te.getBlockType()).getTextureOnSide(EnumFacing.SOUTH, blockFacing)); drawSide(tessellator.getBuffer()); tessellator.draw(); GlStateManager.rotate(90, 0, 1, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(((BlockMachineSided) te.getBlockType()).getTextureOnSide(EnumFacing.EAST, blockFacing)); drawSide(tessellator.getBuffer()); tessellator.draw(); GlStateManager.rotate(90, 0, 1, 0); GlStateManager.rotate(90, 1, 0, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(((BlockMachineSided) te.getBlockType()).getTextureOnSide(EnumFacing.UP, blockFacing)); drawSide(tessellator.getBuffer()); tessellator.draw(); GlStateManager.rotate(180, 1, 0, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(((BlockMachineSided) te.getBlockType()).getTextureOnSide(EnumFacing.DOWN, blockFacing)); drawSide(tessellator.getBuffer()); tessellator.draw(); GlStateManager.popMatrix(); } private VertexBuffer drawSide(VertexBuffer buffer) { buffer.begin(GL11_GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); buffer.pos(-0.5, -0.5, -0.5).tex(0, 1).normal(-1, 1, -1).endVertex(); buffer.pos(-0.5, 0.5, -0.5).tex(0, 0).normal(-1, 1, 1).endVertex(); buffer.pos(0.5, 0.5, -0.5).tex(1, 0).normal(1, 1, 1).endVertex(); buffer.pos(0.5, -0.5, -0.5).tex(1, 1).normal(1, 1, -1).endVertex(); return buffer; } UPDATE It seems the less light the block has, the brighter it is. That was just an optical illusion. The block doesn't get lit at all.
-
I need theese IProperties for my BlockState JSON, or is there a better way of custom side rendering based on TileEntity data? Tesselator is gone if I remember correctly.
-
Everythings points to the BlockStateContainer class. I noticed the createState method is called repeatedly until I kill java. I noticed it works at 4 - 6 IProperties too, but it takes 5 seconds for 4 props and about a minute for 6 props. EDIT Wait, does BlockStateContainer on creation generate every single combination of IProperty values? If so, that would be 6 million combinations with 7 Properties (1 side property and 6 properties with 10 different values each).
-
I tried that too before posting, no difference.
-
I have a suspicion the constructor calls itself because of the varargs: public BlockStateContainer(Block blockIn, IProperty<?>... properties) { this(blockIn, properties, null); } ... protected BlockStateContainer(Block blockIn, IProperty<?>[] properties, ImmutableMap<net.minecraftforge.common.property.IUnlistedProperty<?>, com.google.common.base.Optional<?>> unlistedProperties) { ... }
-
I don't know if this is a bug or my error, but MC freezes, when I pass more than one property to the BlockStateContainer. Example code: public static final PropertyDirection FACING = BlockHorizontal.FACING; public static final PropertyEnum<EnumConnectionType> connectionTop = PropertyEnum.create("connection_top", EnumConnectionType.class); public static final PropertyEnum<EnumConnectionType> connectionBottom = PropertyEnum.create("connection_bottom", EnumConnectionType.class); public static final PropertyEnum<EnumConnectionType> connectionNorth = PropertyEnum.create("connection_north", EnumConnectionType.class); public static final PropertyEnum<EnumConnectionType> connectionWest = PropertyEnum.create("connection_right", EnumConnectionType.class); public static final PropertyEnum<EnumConnectionType> connectionSouth = PropertyEnum.create("connection_front", EnumConnectionType.class); public static final PropertyEnum<EnumConnectionType> connectionEast = PropertyEnum.create("connection_back", EnumConnectionType.class); ... @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING, connectionTop, connectionBottom, connectionEast, connectionNorth, connectionSouth, connectionWest); } Am I doing something horribly wrong? If you need to see more code, ask for it.
-
[1.7.10] How to make lightning bolt deal no damage to an entity?
493msi replied to 493msi's topic in Modder Support
Thanks, thats all. -
[1.7.10] How to make lightning bolt deal no damage to an entity?
493msi replied to 493msi's topic in Modder Support
Thank you guys, it looks like I finally did it. Is this the best soulution? @SubscribeEvent public void onEntityStruckByLightning(EntityStruckByLightningEvent event) { if(event.entity.getUniqueID().toString().equals(((LightningBoltExtended) event.lightning.getExtendedProperties("ChargedStrikeCreator")).getCreator())) { event.setCanceled(true); } } public void func_151368_a(EntityLivingBase entLB, Entity entity, int level) { EntityLightningBolt lightning = new EntityLightningBolt(entity.worldObj, entity.posX, entity.posY, entity.posZ); entity.worldObj.addWeatherEffect(lightning); lightning.registerExtendedProperties("ChargedStrikeCreator", new LightningBoltExtended()); LightningBoltExtended prop = (LightningBoltExtended) lightning.getExtendedProperties("ChargedStrikeCreator"); prop.setCreator(entLB.getUniqueID().toString()); } public class LightningBoltExtended implements IExtendedEntityProperties { public final static String subCompound = "chargedStrikeCreator"; protected EntityLightningBolt theEntity; protected World theWorld; public String playerId; @Override public void saveNBTData(NBTTagCompound parCompound) { NBTTagCompound compound = new NBTTagCompound(); parCompound.setTag(subCompound, compound); compound.setString("owner", playerId); } @Override public void loadNBTData(NBTTagCompound parCompound) { NBTTagCompound compound = (NBTTagCompound) parCompound.getTag(subCompound); playerId = parCompound.getString("owner"); } @Override public void init(Entity entity, World world) { theEntity = (EntityLightningBolt)entity; theWorld = world; } public void setCreator(String creator) { playerId = creator; } public String getCreator() { return playerId; } } Sorry about the look of the code, I am quite messy. -
[1.7.10] How to make lightning bolt deal no damage to an entity?
493msi replied to 493msi's topic in Modder Support
When I did this: @SubscribeEvent public void onEntityStruckByLightning(EntityStruckByLightningEvent event) { if(((EntityLivingBase) event.entity).getHeldItem().getItem() == ExtraTools.redSword) { event.setCanceled(true); } } Minecraft crashed when spider I attacked was dying. EDIT: My Forge # is 1199 EDIT2: Realised it now, the spider has no items. EDIT3: Made it working: @SubscribeEvent public void onEntityStruckByLightning(EntityStruckByLightningEvent event) { if(event.entity instanceof EntityLivingBase) if(((EntityLivingBase) event.entity).getHeldItem() != null) if(((EntityLivingBase) event.entity).getHeldItem().getItem() == ExtraTools.redSword) { event.setCanceled(true); } } Now i just need to fix the problem when someone else is in the radius and has that sword (BTW it's the only sword that you can get the enchantment on) -
[1.7.10] How to make lightning bolt deal no damage to an entity?
493msi replied to 493msi's topic in Modder Support
Okay, I will look at it. -
I have this enchantment effect on a sword, however it damages the attacker too. How can I prevent the lightning damage to the holder? Thanks. public void func_151368_a(EntityLivingBase entLB, Entity entity, int level) { EntityLightningBolt lightning = new EntityLightningBolt(entity.worldObj, entity.posX, entity.posY, entity.posZ); entity.worldObj.addWeatherEffect(lightning); }