Work on trying to get it to render, still does not work
This commit is contained in:
parent
214dacffe5
commit
5101abc541
5 changed files with 97 additions and 0 deletions
|
@ -6,6 +6,8 @@ package techreborn.partSystem;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -45,6 +47,13 @@ public interface IModPart {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(Vecs3d translation, double delta);
|
||||
|
||||
/**
|
||||
* Renders this part statically. A tessellator has alredy started drawing. <br>
|
||||
* Only called when there's a block/lighting/render update in the chunk this part is in.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass);
|
||||
|
||||
/**
|
||||
* Writes the part's data to an NBT tag, which is saved with the game data.
|
||||
*/
|
||||
|
|
|
@ -15,6 +15,8 @@ import codechicken.multipart.TMultiPart;
|
|||
import codechicken.multipart.TSlottedPart;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -176,4 +178,13 @@ public class FMPModPart extends TMultiPart implements TSlottedPart, JNormalOcclu
|
|||
iModPart.onRemoved();
|
||||
super.onRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vector3 pos, int pass) {
|
||||
boolean render = false;
|
||||
RenderBlocks renderer = RenderBlocks.getInstance();
|
||||
renderer.blockAccess = getWorld();
|
||||
render = iModPart.renderStatic(new Vecs3d(pos.x, pos.y, pos.z), renderer, pass);
|
||||
return render;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,18 @@ import ic2.api.energy.event.EnergyTileUnloadEvent;
|
|||
import ic2.api.energy.tile.IEnergyConductor;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.core.IC2;
|
||||
import ic2.core.Ic2Items;
|
||||
import ic2.core.block.wiring.RenderBlockCable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.lib.Functions;
|
||||
|
@ -101,6 +108,17 @@ public class CablePart extends ModPart implements IEnergyConductor {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass) {
|
||||
if(worldObj!= null){
|
||||
FakeCableWorld fakeCableWorld = new FakeCableWorld();
|
||||
RenderBlockCable renderBlockCable = new RenderBlockCable();
|
||||
return renderBlockCable.renderWorldBlock(fakeCableWorld, getX(), getY(), getZ(), Block.getBlockFromItem(Ic2Items.copperCableBlock.getItem()) , 0, RenderBlocks.getInstance());
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package techreborn.partSystem.parts;
|
||||
|
||||
import ic2.core.block.wiring.TileEntityCable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
|
||||
|
||||
public class FakeCableWorld extends WorldClient {
|
||||
|
||||
public FakeCableWorld() {
|
||||
super(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(0, WorldSettings.GameType.NOT_SET,
|
||||
false, false, WorldType.DEFAULT), 0, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().theWorld.theProfiler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IChunkProvider createChunkProvider() {
|
||||
return Minecraft.getMinecraft().thePlayer.worldObj.getChunkProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int func_152379_p() {
|
||||
return Minecraft.getMinecraft().gameSettings.renderDistanceChunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntityByID(int p_73045_1_) {
|
||||
return Minecraft.getMinecraft().theWorld.getEntityByID(p_73045_1_);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(int x, int y, int z) {
|
||||
return new TileEntityCable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunkFromBlockCoords(int p_72938_1_, int p_72938_2_) {
|
||||
return Minecraft.getMinecraft().theWorld.getChunkFromBlockCoords(p_72938_1_, p_72938_2_);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package techreborn.partSystem.parts;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -40,6 +41,11 @@ public class NullPart extends ModPart {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue