Started to work on Quantum Gates

This commit is contained in:
Calclavia 2014-03-08 22:30:08 -08:00
parent ce2beb65ee
commit 6a0ffe582e
17 changed files with 334 additions and 16 deletions

View file

@ -18,6 +18,8 @@ import resonantinduction.electrical.render.FXElectricBolt;
import resonantinduction.electrical.tesla.RenderTesla;
import resonantinduction.electrical.tesla.TileTesla;
import resonantinduction.electrical.transformer.RenderTransformer;
import resonantinduction.mechanical.energy.gear.RenderGear;
import resonantinduction.quantum.gate.RenderQuantumGlyph;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.item.GlobalItemRenderer;
import codechicken.multipart.TMultiPart;
@ -39,6 +41,7 @@ public class ClientProxy extends CommonProxy
GlobalItemRenderer.register(Electrical.itemTransformer.itemID, RenderTransformer.INSTANCE);
GlobalItemRenderer.register(Electrical.itemCharger.itemID, RenderCharger.INSTANCE);
GlobalItemRenderer.register(Electrical.itemLevitator.itemID, RenderLevitator.INSTANCE);
GlobalItemRenderer.register(Electrical.itemQuantumGlyph.itemID, RenderQuantumGlyph.INSTANCE);
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel());

View file

@ -31,6 +31,7 @@ import resonantinduction.electrical.wire.EnumWireMaterial;
import resonantinduction.electrical.wire.ItemWire;
import resonantinduction.quantum.gate.BlockGlyph;
import resonantinduction.quantum.gate.BlockQuantumGate;
import resonantinduction.quantum.gate.ItemQuantumGlyph;
import resonantinduction.quantum.gate.TileQuantumGate;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketHandler;
@ -94,8 +95,8 @@ public class Electrical
public static Item itemDisk;
// Quantum
public static Block blockGlyph;
public static Block blockQuantumGate;
public static Item itemQuantumGlyph;
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
@ -124,9 +125,8 @@ public class Electrical
blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class);
// Quantum
blockGlyph = contentRegistry.createBlock(BlockGlyph.class, ItemBlockMetadata.class);
blockQuantumGate = contentRegistry.createTile(BlockQuantumGate.class, TileQuantumGate.class);
itemQuantumGlyph = contentRegistry.createItem(ItemQuantumGlyph.class);
Settings.save();
OreDictionary.registerOre("wire", itemWire);

View file

@ -8,6 +8,7 @@ import resonantinduction.electrical.wire.flat.PartFlatSwitchWire;
import resonantinduction.electrical.wire.flat.PartFlatWire;
import resonantinduction.electrical.wire.framed.PartFramedSwitchWire;
import resonantinduction.electrical.wire.framed.PartFramedWire;
import resonantinduction.quantum.gate.PartQuantumGlyph;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator;
@ -17,7 +18,7 @@ public class MultipartElectrical implements IPartFactory
{
public static MultipartElectrical INSTANCE;
public static final String[] PART_TYPES = { "resonant_induction_wire", "resonant_induction_switch_wire", "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer", "resonant_induction_charger", "resonant_induction_levitator" };
public static final String[] PART_TYPES = { "resonant_induction_quantum_glyph", "resonant_induction_wire", "resonant_induction_switch_wire", "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer", "resonant_induction_charger", "resonant_induction_levitator" };
public MultipartElectrical()
{
@ -47,6 +48,8 @@ public class MultipartElectrical implements IPartFactory
return new PartCharger();
else if (name.equals("resonant_induction_levitator"))
return new PartLevitator();
else if (name.equals("resonant_induction_quantum_glyph"))
return new PartQuantumGlyph();
return null;
}

View file

@ -34,4 +34,10 @@ public class ItemCharger extends JItemMultiPart implements IHighlight
return part;
}
@Override
public int getHighlightType()
{
return 0;
}
}

View file

@ -34,4 +34,10 @@ public class ItemLevitator extends JItemMultiPart implements IHighlight
return part;
}
@Override
public int getHighlightType()
{
return 0;
}
}

View file

@ -81,4 +81,10 @@ public class ItemMultimeter extends JItemMultiPart implements IHighlight
itemStack.stackTagCompound.setFloat("detection", detection);
}
@Override
public int getHighlightType()
{
return 0;
}
}

View file

@ -34,4 +34,10 @@ public class ItemTransformer extends JItemMultiPart implements IHighlight
return part;
}
@Override
public int getHighlightType()
{
return 0;
}
}

View file

@ -36,14 +36,9 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemWire extends JItemMultiPart
{
public ItemWire()
{
this(Settings.getNextItemID());
}
public ItemWire(int id)
{
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id));
super(id);
this.setUnlocalizedName(Reference.PREFIX + "wire");
this.setTextureName(Reference.PREFIX + "wire");
this.setCreativeTab(TabRI.DEFAULT);

View file

@ -0,0 +1,95 @@
package resonantinduction.quantum.gate;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.core.prefab.part.IHighlight;
import resonantinduction.mechanical.energy.gear.PartGearShaft;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.CornerPlacementGrid$;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.PartMap;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
public class ItemQuantumGlyph extends JItemMultiPart implements IHighlight
{
public ItemQuantumGlyph(int id)
{
super(id);
setHasSubtypes(true);
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage();
}
@Override
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int slot, Vector3 hit)
{
PartQuantumGlyph part = (PartQuantumGlyph) MultiPartRegistry.createPart("resonant_induction_quantum_glyph", false);
slot = CornerPlacementGrid$.MODULE$.getHitSlot(hit, slot);
System.out.println(slot);
switch (slot)
{
case 7:
slot = 0;
break;
case 9:
slot = 1;
break;
case 11:
slot = 2;
break;
case 13:
slot = 3;
break;
case 8:
slot = 4;
break;
case 10:
slot = 5;
break;
case 12:
slot = 6;
break;
case 14:
slot = 7;
break;
}
TileEntity tile = world.getBlockTileEntity(pos.x, pos.y, pos.z);
if (tile instanceof TileMultipart)
{
}
part.preparePlacement(slot, itemStack.getItemDamage());
return part;
}
@Override
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
{
for (int i = 0; i < 4; i++)
{
listToAddTo.add(new ItemStack(itemID, 1, i));
}
}
@Override
public int getHighlightType()
{
return 1;
}
}

View file

@ -0,0 +1,127 @@
package resonantinduction.quantum.gate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import resonantinduction.core.Reference;
import resonantinduction.electrical.Electrical;
import calclavia.lib.render.RenderUtility;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.JCuboidPart;
import codechicken.multipart.JNormalOcclusion;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartQuantumGlyph extends JCuboidPart implements JNormalOcclusion
{
static final Cuboid6[] bounds = new Cuboid6[8];
static
{
bounds[0] = new Cuboid6(0, 0, 0, 0.5, 0.5, 0.5);
bounds[1] = new Cuboid6(0, 0, 0.5, 0.5, 0.5, 1);
bounds[2] = new Cuboid6(0.5, 0, 0, 1, 0.5, 0.5);
bounds[3] = new Cuboid6(0.5, 0, 0.5, 1, 0.5, 1);
bounds[4] = new Cuboid6(0, 0.5, 0, 0.5, 1, 0.5);
bounds[5] = new Cuboid6(0, 0.5, 0.5, 0.5, 1, 1);
bounds[6] = new Cuboid6(0.5, 0.5, 0, 1, 1, 0.5);
bounds[7] = new Cuboid6(0.5, 0.5, 0.5, 1, 1, 1);
}
private byte side;
byte number;
public void preparePlacement(int side, int itemDamage)
{
this.side = (byte) side;
this.number = (byte) itemDamage;
}
@Override
public String getType()
{
return "resonant_induction_quantum_glyph";
}
@SideOnly(Side.CLIENT)
@Override
public void renderDynamic(Vector3 pos, float frame, int pass)
{
RenderQuantumGlyph.INSTANCE.render(this, pos.x, pos.y, pos.z);
}
@Override
public Cuboid6 getBounds()
{
if (side < bounds.length)
if (bounds[side] != null)
return bounds[side];
return new Cuboid6(0, 0, 0, 0.5, 0.5, 0.5);
}
@Override
public Iterable<Cuboid6> getOcclusionBoxes()
{
return Arrays.asList(new Cuboid6[] { getBounds() });
}
protected ItemStack getItem()
{
return new ItemStack(Electrical.itemQuantumGlyph);
}
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getItem());
return drops;
}
@Override
public ItemStack pickItem(MovingObjectPosition hit)
{
return getItem();
}
/** Packet Code. */
@Override
public void readDesc(MCDataInput packet)
{
load(packet.readNBTTagCompound());
}
@Override
public void writeDesc(MCDataOutput packet)
{
// packet.writeByte(0);
NBTTagCompound nbt = new NBTTagCompound();
save(nbt);
packet.writeNBTTagCompound(nbt);
}
@Override
public void load(NBTTagCompound nbt)
{
side = nbt.getByte("side");
number = nbt.getByte("number");
}
@Override
public void save(NBTTagCompound nbt)
{
nbt.setByte("side", side);
nbt.setByte("number", number);
}
}

View file

@ -0,0 +1,43 @@
package resonantinduction.quantum.gate;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import resonantinduction.core.Reference;
import resonantinduction.electrical.Electrical;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.render.item.ISimpleItemRenderer;
import cpw.mods.fml.client.FMLClientHandler;
public class RenderQuantumGlyph implements ISimpleItemRenderer
{
public static final RenderQuantumGlyph INSTANCE = new RenderQuantumGlyph();
public void render(PartQuantumGlyph part, double x, double y, double z)
{
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
Cuboid6 bound = part.getBounds().copy();
bound.expand(-0.02);
RenderUtility.bind(TextureMap.locationBlocksTexture);
RenderUtility.renderCube(bound.min.x, bound.min.y, bound.min.z, bound.max.x, bound.max.y, bound.max.z, Block.stone, RenderUtility.getIcon(Reference.PREFIX + "glyph_" + part.number));
GL11.glPopMatrix();
}
@Override
public void renderInventoryItem(ItemStack itemStack)
{
GL11.glPushMatrix();
RenderUtility.bind(TextureMap.locationBlocksTexture);
RenderUtility.renderCube(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5, Block.stone, RenderUtility.getIcon(Reference.PREFIX + "glyph_" + itemStack.getItemDamage()));
GL11.glPopMatrix();
}
}

View file

@ -10,6 +10,7 @@ import resonantinduction.core.prefab.part.IHighlight;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.FacePlacementGrid$;
import codechicken.microblock.CornerPlacementGrid$;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -24,7 +25,16 @@ public class MicroblockHighlightHandler
GL11.glPushMatrix();
RenderUtils.translateToWorldCoords(event.player, event.partialTicks);
Vector3 hit = new Vector3(event.target.hitVec);
FacePlacementGrid$.MODULE$.render(hit, event.target.sideHit);
switch (((IHighlight) event.currentItem.getItem()).getHighlightType())
{
case 0:
FacePlacementGrid$.MODULE$.render(hit, event.target.sideHit);
break;
case 1:
CornerPlacementGrid$.MODULE$.render(hit, event.target.sideHit);
}
event.setCanceled(true);
GL11.glPopMatrix();
}

View file

@ -63,4 +63,10 @@ public class ItemGear extends JItemMultiPart implements IHighlight
listToAddTo.add(new ItemStack(itemID, 1, i));
}
}
@Override
public int getHighlightType()
{
return 0;
}
}

View file

@ -48,4 +48,10 @@ public class ItemGearShaft extends JItemMultiPart implements IHighlight
listToAddTo.add(new ItemStack(itemID, 1, i));
}
}
@Override
public int getHighlightType()
{
return 0;
}
}

View file

@ -23,6 +23,11 @@ public class TextureHookHandler
{
if (event.map.textureType == 0)
{
RenderUtility.registerIcon(Reference.PREFIX + "glyph_0", event.map);
RenderUtility.registerIcon(Reference.PREFIX + "glyph_1", event.map);
RenderUtility.registerIcon(Reference.PREFIX + "glyph_2", event.map);
RenderUtility.registerIcon(Reference.PREFIX + "glyph_3", event.map);
RenderUtility.registerIcon(Reference.PREFIX + "mixture_flow", event.map);
RenderUtility.registerIcon(Reference.PREFIX + "molten_flow", event.map);
RenderUtility.registerIcon(Reference.PREFIX + "multimeter_screen", event.map);

View file

@ -2,5 +2,5 @@ package resonantinduction.core.prefab.part;
public interface IHighlight
{
public int getHighlightType();
}

View file

@ -147,10 +147,11 @@ item.resonantinduction\:multimeter.tooltip=Multimeter is a panel that display th
### Quantum Tier
tile.resonantinduction\:quantumGate.name=Quantum Gate
tile.resonantinduction\:glyph.0.name=Monogon Glyph
tile.resonantinduction\:glyph.1.name=Digon Glyph
tile.resonantinduction\:glyph.2.name=Trigon Glyph
tile.resonantinduction\:glyph.3.name=Tetragon Glyph
item.resonantinduction\:quantumGlyph.0.name=Nought Glyph
item.resonantinduction\:quantumGlyph.1.name=Monogon Glyph
item.resonantinduction\:quantumGlyph.2.name=Digon Glyph
item.resonantinduction\:quantumGlyph.3.name=Trigon Glyph
item.resonantinduction\:quantumGlyph.4.name=Tetragon Glyph
## Tool-tips
tooltip.pipe.rate=Flow Rate: %v