It renders! sort of
This commit is contained in:
parent
4b7b9d4fd2
commit
293a8fbcaf
3 changed files with 51 additions and 10 deletions
|
@ -4,12 +4,15 @@
|
|||
|
||||
package techreborn.partSystem.QLib;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import uk.co.qmunity.lib.client.render.RenderHelper;
|
||||
import uk.co.qmunity.lib.part.IPart;
|
||||
import uk.co.qmunity.lib.part.IPartCollidable;
|
||||
import uk.co.qmunity.lib.part.IPartRenderPlacement;
|
||||
|
@ -22,6 +25,7 @@ import uk.co.qmunity.lib.raytrace.QMovingObjectPosition;
|
|||
import uk.co.qmunity.lib.raytrace.RayTracer;
|
||||
import uk.co.qmunity.lib.vec.Vec3d;
|
||||
import uk.co.qmunity.lib.vec.Vec3dCube;
|
||||
import uk.co.qmunity.lib.vec.Vec3i;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -66,6 +70,11 @@ public class QModPart extends PartBase implements IPartCollidable, IPartSelectab
|
|||
iModPart.renderDynamic(ModLib2QLib.convert(translation), delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
|
||||
return iModPart.renderStatic(new Vecs3d(translation.getX(), translation.getY(), translation.getZ()),renderBlocks , pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) {
|
||||
return RayTracer.instance().rayTraceCubes(this, start, end);
|
||||
|
|
|
@ -8,15 +8,12 @@ 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;
|
||||
|
@ -107,16 +104,24 @@ public class CablePart extends ModPart implements IEnergyConductor {
|
|||
public void renderDynamic(Vecs3d translation, double delta) {
|
||||
|
||||
}
|
||||
//TODO make this static for all cables in the world.
|
||||
FakeCableWorld fakeCableWorld;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass) {
|
||||
if(worldObj!= null){
|
||||
FakeCableWorld fakeCableWorld = new FakeCableWorld();
|
||||
if(fakeCableWorld == null){
|
||||
fakeCableWorld = new FakeCableWorld();
|
||||
}
|
||||
RenderBlockCable renderBlockCable = new RenderBlockCable();
|
||||
return renderBlockCable.renderWorldBlock(fakeCableWorld, getX(), getY(), getZ(), Block.getBlockFromItem(Ic2Items.copperCableBlock.getItem()) , 0, RenderBlocks.getInstance());
|
||||
|
||||
}
|
||||
return false;
|
||||
// renderBlocks.renderBlockAllFaces(Blocks.coal_block, getX(), getY(), getZ());
|
||||
// renderBlocks.renderStandardBlock(Blocks.coal_block, getX(), getY() + 1, getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package techreborn.partSystem.parts;
|
||||
|
||||
import ic2.core.Ic2Items;
|
||||
import ic2.core.block.wiring.TileEntityCable;
|
||||
import net.minecraft.block.Block;
|
||||
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 int meta;
|
||||
|
||||
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);
|
||||
|
@ -43,11 +43,38 @@ public class FakeCableWorld extends WorldClient {
|
|||
|
||||
@Override
|
||||
public TileEntity getTileEntity(int x, int y, int z) {
|
||||
return new TileEntityCable();
|
||||
TileEntityCable cable = new TileEntityCable();
|
||||
cable.setWorldObj(this);
|
||||
cable.changeFoam((byte) 1);
|
||||
cable.changeType((short) 2);
|
||||
cable.xCoord = x;
|
||||
cable.yCoord = y;
|
||||
cable.zCoord = z;
|
||||
cable.connectivity = (byte)3;
|
||||
cable.blockType = Block.getBlockFromItem(Ic2Items.copperCableBlock.getItem());
|
||||
cable.onRender();
|
||||
|
||||
return cable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunkFromBlockCoords(int p_72938_1_, int p_72938_2_) {
|
||||
return Minecraft.getMinecraft().theWorld.getChunkFromBlockCoords(p_72938_1_, p_72938_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlockMetadataWithNotify(int p_72921_1_, int p_72921_2_, int p_72921_3_, int p_72921_4_, int p_72921_5_) {
|
||||
meta = p_72921_4_;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) {
|
||||
return Block.getBlockFromItem(Ic2Items.copperCableBlock.getItem());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue