feat: opensourced RP2 port

This commit is contained in:
Timo Ley 2022-12-22 17:22:45 +01:00
parent a638e4b8cf
commit e00be36154
1692 changed files with 62734 additions and 1 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.idea
build
run
bin

View File

@ -34,10 +34,16 @@ minecraft {
repositories {
maven { url = "https://maven.tilera.xyz" }
maven {
name 'central'
url 'https://maven.thorfusion.com/artifactory/central/'
}
}
dependencies {
implementation "codechicken:CodeChickenLib:1.7.10-1.1.3.141:dev"
implementation "codechicken:NotEnoughItems:1.7.10-1.0.5.120:dev"
implementation "codechicken:CodeChickenCore:1.7.10-1.0.7.48:dev"
}
processResources {

View File

@ -0,0 +1,8 @@
package cofh.api;
public class CoFHAPIProps {
public static final String VERSION = "1.7.10R1.3.1";
private CoFHAPIProps() {
}
}

View File

@ -0,0 +1,121 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
public class EnergyStorage implements IEnergyStorage {
protected int energy;
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public EnergyStorage(int capacity) {
this(capacity, capacity, capacity);
}
public EnergyStorage(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
this.energy = nbt.getInteger("Energy");
if (this.energy > this.capacity) {
this.energy = this.capacity;
}
return this;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
if (this.energy < 0) {
this.energy = 0;
}
nbt.setInteger("Energy", this.energy);
return nbt;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
if (this.energy > capacity) {
this.energy = capacity;
}
}
public void setMaxTransfer(int maxTransfer) {
this.setMaxReceive(maxTransfer);
this.setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
public int getMaxReceive() {
return this.maxReceive;
}
public int getMaxExtract() {
return this.maxExtract;
}
public void setEnergyStored(int energy) {
this.energy = energy;
if (this.energy > this.capacity) {
this.energy = this.capacity;
} else if (this.energy < 0) {
this.energy = 0;
}
}
public void modifyEnergyStored(int energy) {
this.energy += energy;
if (this.energy > this.capacity) {
this.energy = this.capacity;
} else if (this.energy < 0) {
this.energy = 0;
}
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(this.capacity - this.energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) {
this.energy += energyReceived;
}
return energyReceived;
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
int energyExtracted = Math.min(this.energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) {
this.energy -= energyExtracted;
}
return energyExtracted;
}
@Override
public int getEnergyStored() {
return this.energy;
}
@Override
public int getMaxEnergyStored() {
return this.capacity;
}
}

View File

@ -0,0 +1,7 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyConnection {
boolean canConnectEnergy(ForgeDirection var1);
}

View File

@ -0,0 +1,13 @@
package cofh.api.energy;
import net.minecraft.item.ItemStack;
public interface IEnergyContainerItem {
int receiveEnergy(ItemStack var1, int var2, boolean var3);
int extractEnergy(ItemStack var1, int var2, boolean var3);
int getEnergyStored(ItemStack var1);
int getMaxEnergyStored(ItemStack var1);
}

View File

@ -0,0 +1,17 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver {
@Override
int receiveEnergy(ForgeDirection var1, int var2, boolean var3);
@Override
int extractEnergy(ForgeDirection var1, int var2, boolean var3);
@Override
int getEnergyStored(ForgeDirection var1);
@Override
int getMaxEnergyStored(ForgeDirection var1);
}

View File

@ -0,0 +1,11 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyProvider extends IEnergyConnection {
int extractEnergy(ForgeDirection var1, int var2, boolean var3);
int getEnergyStored(ForgeDirection var1);
int getMaxEnergyStored(ForgeDirection var1);
}

View File

@ -0,0 +1,11 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyReceiver extends IEnergyConnection {
int receiveEnergy(ForgeDirection var1, int var2, boolean var3);
int getEnergyStored(ForgeDirection var1);
int getMaxEnergyStored(ForgeDirection var1);
}

View File

@ -0,0 +1,11 @@
package cofh.api.energy;
public interface IEnergyStorage {
int receiveEnergy(int var1, boolean var2);
int extractEnergy(int var1, boolean var2);
int getEnergyStored();
int getMaxEnergyStored();
}

View File

@ -0,0 +1,34 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyTransport extends IEnergyProvider, IEnergyReceiver {
@Override
int getEnergyStored(ForgeDirection var1);
IEnergyTransport.InterfaceType getTransportState(ForgeDirection var1);
boolean setTransportState(IEnergyTransport.InterfaceType var1, ForgeDirection var2);
public static enum InterfaceType {
SEND,
RECEIVE,
BALANCE;
public IEnergyTransport.InterfaceType getOpposite() {
return this == BALANCE ? BALANCE : (this == SEND ? RECEIVE : SEND);
}
public IEnergyTransport.InterfaceType rotate() {
return this.rotate(true);
}
public IEnergyTransport.InterfaceType rotate(boolean forward) {
if (forward) {
return this == BALANCE ? RECEIVE : (this == RECEIVE ? SEND : BALANCE);
} else {
return this == BALANCE ? SEND : (this == SEND ? RECEIVE : BALANCE);
}
}
}
}

View File

@ -0,0 +1,88 @@
package cofh.api.energy;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public ItemEnergyContainer() {
}
public ItemEnergyContainer(int capacity) {
this(capacity, capacity, capacity);
}
public ItemEnergyContainer(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public ItemEnergyContainer setCapacity(int capacity) {
this.capacity = capacity;
return this;
}
public void setMaxTransfer(int maxTransfer) {
this.setMaxReceive(maxTransfer);
this.setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (container.stackTagCompound == null) {
container.stackTagCompound = new NBTTagCompound();
}
int energy = container.stackTagCompound.getInteger("Energy");
int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) {
energy += energyReceived;
container.stackTagCompound.setInteger("Energy", energy);
}
return energyReceived;
}
@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if (container.stackTagCompound != null && container.stackTagCompound.hasKey("Energy")) {
int energy = container.stackTagCompound.getInteger("Energy");
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) {
energy -= energyExtracted;
container.stackTagCompound.setInteger("Energy", energy);
}
return energyExtracted;
} else {
return 0;
}
}
@Override
public int getEnergyStored(ItemStack container) {
return container.stackTagCompound != null && container.stackTagCompound.hasKey("Energy") ? container.stackTagCompound.getInteger("Energy") : 0;
}
@Override
public int getMaxEnergyStored(ItemStack container) {
return this.capacity;
}
}

View File

@ -0,0 +1,44 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
protected EnergyStorage storage = new EnergyStorage(32000);
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.storage.readFromNBT(nbt);
}
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
this.storage.writeToNBT(nbt);
}
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return true;
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return this.storage.receiveEnergy(maxReceive, simulate);
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return this.storage.extractEnergy(maxExtract, simulate);
}
@Override
public int getEnergyStored(ForgeDirection from) {
return this.storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return this.storage.getMaxEnergyStored();
}
}

View File

@ -0,0 +1,6 @@
package com.eloraam.redpower;
public class Flags {
public static final boolean SERVER = true;
public static final boolean CLIENT = true;
}

View File

@ -0,0 +1,525 @@
package com.eloraam.redpower;
import com.eloraam.redpower.base.BlockAppliance;
import com.eloraam.redpower.base.BlockMicro;
import com.eloraam.redpower.base.ContainerAdvBench;
import com.eloraam.redpower.base.ContainerAlloyFurnace;
import com.eloraam.redpower.base.ContainerBag;
import com.eloraam.redpower.base.ContainerBusId;
import com.eloraam.redpower.base.GuiAdvBench;
import com.eloraam.redpower.base.GuiAlloyFurnace;
import com.eloraam.redpower.base.GuiBag;
import com.eloraam.redpower.base.GuiBusId;
import com.eloraam.redpower.base.ItemBag;
import com.eloraam.redpower.base.ItemDrawplate;
import com.eloraam.redpower.base.ItemDyeIndigo;
import com.eloraam.redpower.base.ItemHandsaw;
import com.eloraam.redpower.base.ItemMicro;
import com.eloraam.redpower.base.ItemPlan;
import com.eloraam.redpower.base.ItemScrewdriver;
import com.eloraam.redpower.base.RecipeBag;
import com.eloraam.redpower.base.RenderAdvBench;
import com.eloraam.redpower.base.RenderAlloyFurnace;
import com.eloraam.redpower.base.TileAdvBench;
import com.eloraam.redpower.base.TileAlloyFurnace;
import com.eloraam.redpower.core.AchieveLib;
import com.eloraam.redpower.core.BlockMultiblock;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CoverLib;
import com.eloraam.redpower.core.CraftLib;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.ItemExtended;
import com.eloraam.redpower.core.ItemParts;
import com.eloraam.redpower.core.OreStack;
import com.eloraam.redpower.core.RenderLib;
import com.eloraam.redpower.core.TileCovered;
import com.eloraam.redpower.core.TileMultiblock;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.stats.AchievementList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent.Pre;
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
@Mod(
modid = "RedPowerBase",
name = "RedPower Base",
version = "2.0pr6",
dependencies = "required-after:RedPowerCore"
)
public class RedPowerBase implements IGuiHandler {
@Instance("RedPowerBase")
public static RedPowerBase instance;
public static BlockAppliance blockAppliance;
public static Item itemHandsawIron;
public static Item itemHandsawDiamond;
public static ItemParts itemLumar;
public static ItemParts itemResource;
public static ItemStack itemRuby;
public static ItemStack itemGreenSapphire;
public static ItemStack itemSapphire;
public static ItemStack itemIngotSilver;
public static ItemStack itemIngotTin;
public static ItemStack itemIngotCopper;
public static ItemStack itemIngotTungsten;
public static ItemStack itemDustTungsten;
public static ItemStack itemDustSilver;
public static ItemStack itemNikolite;
public static ItemParts itemAlloy;
public static ItemStack itemIngotRed;
public static ItemStack itemIngotBlue;
public static ItemStack itemIngotBrass;
public static ItemStack itemBouleSilicon;
public static ItemStack itemWaferSilicon;
public static ItemStack itemWaferBlue;
public static ItemStack itemWaferRed;
public static ItemStack itemTinplate;
public static ItemStack itemFineCopper;
public static ItemStack itemFineIron;
public static ItemStack itemCopperCoil;
public static ItemStack itemMotor;
public static ItemStack itemCanvas;
public static ItemParts itemNugget;
public static ItemStack itemNuggetIron;
public static ItemStack itemNuggetSilver;
public static ItemStack itemNuggetTin;
public static ItemStack itemNuggetCopper;
public static ItemStack itemNuggetTungsten;
public static Item itemDyeIndigo;
public static BlockMicro blockMicro;
public static BlockMultiblock blockMultiblock;
public static ItemScrewdriver itemScrewdriver;
public static Item itemDrawplateDiamond;
public static Item itemPlanBlank;
public static Item itemPlanFull;
public static Item itemBag;
@SideOnly(Side.CLIENT)
public static IIcon projectTableTop;
@SideOnly(Side.CLIENT)
public static IIcon projectTableBottom;
@SideOnly(Side.CLIENT)
public static IIcon projectTableFront;
@SideOnly(Side.CLIENT)
public static IIcon projectTableSide;
@SideOnly(Side.CLIENT)
public static IIcon alloyFurnaceVert;
@SideOnly(Side.CLIENT)
public static IIcon alloyFurnaceSide;
@SideOnly(Side.CLIENT)
public static IIcon alloyFurnaceFront;
@SideOnly(Side.CLIENT)
public static IIcon alloyFurnaceFrontOn;
public static void initBaseItems() {
itemLumar = new ItemParts();
itemLumar.setCreativeTab(CreativeTabs.tabMaterials);
for(int color = 0; color < 16; ++color) {
itemLumar.addItem(color, "rpbase:lumar/" + color, "item.rplumar." + CoreLib.rawColorNames[color]);
ItemStack dye = new ItemStack(Items.dye, 1, 15 - color);
GameRegistry.addShapelessRecipe(new ItemStack(itemLumar, 2, color), new Object[]{Items.redstone, dye, dye, Items.glowstone_dust});
}
itemResource = new ItemParts();
itemAlloy = new ItemParts();
itemResource.setCreativeTab(CreativeTabs.tabMaterials);
itemAlloy.setCreativeTab(CreativeTabs.tabMaterials);
itemResource.addItem(0, "rpbase:ruby", "item.ruby");
itemResource.addItem(1, "rpbase:greenSapphire", "item.greenSapphire");
itemResource.addItem(2, "rpbase:sapphire", "item.sapphire");
itemResource.addItem(3, "rpbase:silverIngot", "item.ingotSilver");
itemResource.addItem(4, "rpbase:tinIngot", "item.ingotTin");
itemResource.addItem(5, "rpbase:copperIngot", "item.ingotCopper");
itemResource.addItem(6, "rpbase:nikolite", "item.nikolite");
itemResource.addItem(7, "rpbase:ingotTungsten", "item.ingotTungsten");
itemResource.addItem(8, "rpbase:dustTungsten", "item.dustTungsten");
itemResource.addItem(9, "rpbase:dustSilver", "item.dustSilver");
itemAlloy.addItem(0, "rpbase:ingotRed", "item.ingotRed");
itemAlloy.addItem(1, "rpbase:ingotBlue", "item.ingotBlue");
itemAlloy.addItem(2, "rpbase:ingotBrass", "item.ingotBrass");
itemAlloy.addItem(3, "rpbase:bouleSilicon", "item.bouleSilicon");
itemAlloy.addItem(4, "rpbase:waferSilicon", "item.waferSilicon");
itemAlloy.addItem(5, "rpbase:waferBlue", "item.waferBlue");
itemAlloy.addItem(6, "rpbase:waferRed", "item.waferRed");
itemAlloy.addItem(7, "rpbase:tinPlate", "item.tinplate");
itemAlloy.addItem(8, "rpbase:fineCopper", "item.finecopper");
itemAlloy.addItem(9, "rpbase:fineIron", "item.fineiron");
itemAlloy.addItem(10, "rpbase:copperCoil", "item.coppercoil");
itemAlloy.addItem(11, "rpbase:btMotor", "item.btmotor");
itemAlloy.addItem(12, "rpbase:canvas", "item.rpcanvas");
itemRuby = new ItemStack(itemResource, 1, 0);
itemGreenSapphire = new ItemStack(itemResource, 1, 1);
itemSapphire = new ItemStack(itemResource, 1, 2);
itemIngotSilver = new ItemStack(itemResource, 1, 3);
itemIngotTin = new ItemStack(itemResource, 1, 4);
itemIngotCopper = new ItemStack(itemResource, 1, 5);
itemNikolite = new ItemStack(itemResource, 1, 6);
itemIngotTungsten = new ItemStack(itemResource, 1, 7);
itemDustTungsten = new ItemStack(itemResource, 1, 8);
itemDustSilver = new ItemStack(itemResource, 1, 9);
itemIngotRed = new ItemStack(itemAlloy, 1, 0);
itemIngotBlue = new ItemStack(itemAlloy, 1, 1);
itemIngotBrass = new ItemStack(itemAlloy, 1, 2);
itemBouleSilicon = new ItemStack(itemAlloy, 1, 3);
itemWaferSilicon = new ItemStack(itemAlloy, 1, 4);
itemWaferBlue = new ItemStack(itemAlloy, 1, 5);
itemWaferRed = new ItemStack(itemAlloy, 1, 6);
itemTinplate = new ItemStack(itemAlloy, 1, 7);
itemFineCopper = new ItemStack(itemAlloy, 1, 8);
itemFineIron = new ItemStack(itemAlloy, 1, 9);
itemCopperCoil = new ItemStack(itemAlloy, 1, 10);
itemMotor = new ItemStack(itemAlloy, 1, 11);
itemCanvas = new ItemStack(itemAlloy, 1, 12);
itemNugget = new ItemParts();
itemNugget.setCreativeTab(CreativeTabs.tabMaterials);
itemNugget.addItem(0, "rpbase:nuggetIron", "item.nuggetIron");
itemNugget.addItem(1, "rpbase:nuggetSilver", "item.nuggetSilver");
itemNugget.addItem(2, "rpbase:nuggetTin", "item.nuggetTin");
itemNugget.addItem(3, "rpbase:nuggetCopper", "item.nuggetCopper");
itemNugget.addItem(4, "rpbase:nuggetTungsten", "item.nuggetTungsten");
itemNuggetIron = new ItemStack(itemNugget, 1, 0);
itemNuggetSilver = new ItemStack(itemNugget, 1, 1);
itemNuggetTin = new ItemStack(itemNugget, 1, 2);
itemNuggetCopper = new ItemStack(itemNugget, 1, 3);
itemNuggetTungsten = new ItemStack(itemNugget, 1, 4);
itemDrawplateDiamond = new ItemDrawplate();
itemDrawplateDiamond.setUnlocalizedName("drawplateDiamond").setMaxDamage(255).setTextureName("rpbase:diamondDrawplate");
GameRegistry.registerItem(itemDrawplateDiamond, "drawplateDiamond");
itemBag = new ItemBag();
GameRegistry.addRecipe(new ItemStack(itemBag, 1, 0), new Object[]{"CCC", "C C", "CCC", 'C', itemCanvas});
for(int color = 1; color < 16; ++color) {
GameRegistry.addRecipe(
new ItemStack(itemBag, 1, color), new Object[]{"CCC", "CDC", "CCC", 'C', itemCanvas, 'D', new ItemStack(Items.dye, 1, 15 - color)}
);
}
GameRegistry.registerItem(itemLumar, "lumar");
GameRegistry.registerItem(itemResource, "resource");
OreDictionary.registerOre("gemRuby", itemRuby);
OreDictionary.registerOre("gemGreenSapphire", itemGreenSapphire);
OreDictionary.registerOre("gemSapphire", itemSapphire);
OreDictionary.registerOre("ingotTin", itemIngotTin);
OreDictionary.registerOre("ingotCopper", itemIngotCopper);
OreDictionary.registerOre("ingotSilver", itemIngotSilver);
OreDictionary.registerOre("ingotTungsten", itemIngotTungsten);
OreDictionary.registerOre("dustNikolite", itemNikolite);
OreDictionary.registerOre("dustTungsten", itemDustTungsten);
GameRegistry.registerItem(itemAlloy, "alloy");
OreDictionary.registerOre("ingotBrass", itemIngotBrass);
GameRegistry.registerItem(itemNugget, "nugget");
OreDictionary.registerOre("nuggetIron", itemNuggetIron);
OreDictionary.registerOre("nuggetSilver", itemNuggetSilver);
OreDictionary.registerOre("nuggetTin", itemNuggetTin);
OreDictionary.registerOre("nuggetCopper", itemNuggetCopper);
OreDictionary.registerOre("nuggetTungsten", itemNuggetTungsten);
GameRegistry.registerItem(itemBag, "canvasBag");
}
public static void initIndigo() {
itemDyeIndigo = new ItemDyeIndigo();
GameRegistry.registerItem(itemDyeIndigo, "dyeIndigo");
OreDictionary.registerOre("dyeBlue", new ItemStack(itemDyeIndigo));
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.wool, 1, 11), new Object[]{itemDyeIndigo, Blocks.wool});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 12), new Object[]{itemDyeIndigo, new ItemStack(Items.dye, 1, 15)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 6), new Object[]{itemDyeIndigo, new ItemStack(Items.dye, 1, 2)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 5), new Object[]{itemDyeIndigo, new ItemStack(Items.dye, 1, 1)});
GameRegistry.addShapelessRecipe(
new ItemStack(Items.dye, 3, 13), new Object[]{itemDyeIndigo, new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 9)}
);
GameRegistry.addShapelessRecipe(
new ItemStack(Items.dye, 4, 13),
new Object[]{itemDyeIndigo, new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 15)}
);
CraftLib.addShapelessOreRecipe(new ItemStack(itemLumar, 2, 11), Items.redstone, "dyeBlue", "dyeBlue", Items.glowstone_dust);
CraftLib.addOreRecipe(new ItemStack(itemBag, 1, 11), "CCC", "CDC", "CCC", 'C', itemCanvas, 'D', "dyeBlue");
itemPlanBlank = new Item().setTextureName("rpbase:planBlank");
itemPlanBlank.setUnlocalizedName("planBlank");
itemPlanBlank.setCreativeTab(CreativeTabs.tabMisc);
GameRegistry.addShapelessRecipe(new ItemStack(itemPlanBlank), new Object[]{Items.paper, itemDyeIndigo});
GameRegistry.registerItem(itemPlanBlank, "planBlank");
itemPlanFull = new ItemPlan();
GameRegistry.registerItem(itemPlanFull, "planFull");
}
public static void initAlloys() {
CraftLib.addAlloyResult(itemIngotRed, new ItemStack(Items.redstone, 4), new ItemStack(Items.iron_ingot, 1));
CraftLib.addAlloyResult(itemIngotRed, new ItemStack(Items.redstone, 4), new OreStack("ingotCopper"));
CraftLib.addAlloyResult(CoreLib.copyStack(itemIngotBrass, 4), new OreStack("ingotTin"), new OreStack("ingotCopper", 3));
CraftLib.addAlloyResult(CoreLib.copyStack(itemTinplate, 4), new OreStack("ingotTin"), new ItemStack(Items.iron_ingot, 2));
CraftLib.addAlloyResult(itemIngotBlue, new OreStack("ingotSilver"), new OreStack("dustNikolite", 4));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 3), new ItemStack(Blocks.rail, 8));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 3), new ItemStack(Items.bucket, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 5), new ItemStack(Items.minecart, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 6), new ItemStack(Items.iron_door, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 3), new ItemStack(Blocks.iron_bars, 8));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 31), new ItemStack(Blocks.anvil, 1, 0));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 31), new ItemStack(Blocks.anvil, 1, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 31), new ItemStack(Blocks.anvil, 1, 2));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 2), new ItemStack(Items.iron_sword, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 3), new ItemStack(Items.iron_pickaxe, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 3), new ItemStack(Items.iron_axe, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 1), new ItemStack(Items.iron_shovel, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 2), new ItemStack(Items.iron_hoe, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 2), new ItemStack(Items.golden_sword, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 3), new ItemStack(Items.golden_pickaxe, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 3), new ItemStack(Items.golden_axe, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 1), new ItemStack(Items.golden_shovel, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 2), new ItemStack(Items.golden_hoe, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 5), new ItemStack(Items.iron_helmet, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 8), new ItemStack(Items.iron_chestplate, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 7), new ItemStack(Items.iron_leggings, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 4), new ItemStack(Items.iron_boots, 1));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 5), new ItemStack(Items.iron_horse_armor, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 5), new ItemStack(Items.golden_helmet, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 8), new ItemStack(Items.golden_chestplate, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 7), new ItemStack(Items.golden_leggings, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 4), new ItemStack(Items.golden_boots, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 5), new ItemStack(Items.golden_horse_armor, 1));
CraftLib.addAlloyResult(new ItemStack(Items.gold_ingot, 1), new ItemStack(Items.gold_nugget, 9));
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 1), CoreLib.copyStack(itemNuggetIron, 9));
CraftLib.addAlloyResult(itemIngotSilver, CoreLib.copyStack(itemNuggetSilver, 9));
CraftLib.addAlloyResult(itemIngotCopper, CoreLib.copyStack(itemNuggetCopper, 9));
CraftLib.addAlloyResult(itemIngotTin, CoreLib.copyStack(itemNuggetTin, 9));
CraftLib.addAlloyResult(itemIngotTungsten, CoreLib.copyStack(itemNuggetTungsten, 9));
CraftLib.addAlloyResult(itemIngotCopper, itemFineCopper);
CraftLib.addAlloyResult(new ItemStack(Items.iron_ingot, 1), itemFineIron);
CraftLib.addAlloyResult(itemBouleSilicon, new ItemStack(Items.coal, 8, 0), new ItemStack(Blocks.sand, 8));
CraftLib.addAlloyResult(itemBouleSilicon, new ItemStack(Items.coal, 8, 1), new ItemStack(Blocks.sand, 8));
CraftLib.addAlloyResult(itemWaferBlue, CoreLib.copyStack(itemWaferSilicon, 1), new OreStack("dustNikolite", 4));
CraftLib.addAlloyResult(itemWaferRed, CoreLib.copyStack(itemWaferSilicon, 1), new ItemStack(Items.redstone, 4));
}
public static void initMicroblocks() {
blockMicro = new BlockMicro();
blockMicro.setBlockName("rpwire");
GameRegistry.registerBlock(blockMicro, ItemMicro.class, "microblock");
blockMicro.addTileEntityMapping(0, TileCovered::new);
CoverLib.blockCoverPlate = blockMicro;
}
public static void initCoverMaterials() {
CoverLib.addMaterial(0, 1, Blocks.cobblestone, "cobble");
CoverLib.addMaterial(1, 1, Blocks.stone, "stone");
CoverLib.addMaterial(2, 0, Blocks.planks, "planks");
CoverLib.addMaterial(3, 1, Blocks.sandstone, "sandstone");
CoverLib.addMaterial(4, 1, Blocks.mossy_cobblestone, "moss");
CoverLib.addMaterial(5, 1, Blocks.brick_block, "brick");
CoverLib.addMaterial(6, 2, Blocks.obsidian, "obsidian");
CoverLib.addMaterial(7, 1, true, Blocks.glass, "glass");
CoverLib.addMaterial(8, 0, Blocks.dirt, "dirt");
CoverLib.addMaterial(9, 0, Blocks.clay, "clay");
CoverLib.addMaterial(10, 0, Blocks.bookshelf, "books");
CoverLib.addMaterial(11, 0, Blocks.netherrack, "netherrack");
CoverLib.addMaterial(12, 0, Blocks.log, 0, "wood");
CoverLib.addMaterial(13, 0, Blocks.log, 1, "wood1");
CoverLib.addMaterial(14, 0, Blocks.log, 2, "wood2");
CoverLib.addMaterial(15, 0, Blocks.soul_sand, "soul");
CoverLib.addMaterial(16, 1, Blocks.stone_slab, "slab");
CoverLib.addMaterial(17, 1, Blocks.iron_block, "iron");
CoverLib.addMaterial(18, 1, Blocks.gold_block, "gold");
CoverLib.addMaterial(19, 2, Blocks.diamond_block, "diamond");
CoverLib.addMaterial(20, 1, Blocks.lapis_block, "lapis");
CoverLib.addMaterial(21, 0, Blocks.snow, "snow");
CoverLib.addMaterial(22, 0, Blocks.pumpkin, "pumpkin");
CoverLib.addMaterial(23, 1, Blocks.stonebrick, 0, "stonebrick");
CoverLib.addMaterial(24, 1, Blocks.stonebrick, 1, "stonebrick1");
CoverLib.addMaterial(25, 1, Blocks.stonebrick, 2, "stonebrick2");
CoverLib.addMaterial(26, 1, Blocks.nether_brick, "netherbrick");
CoverLib.addMaterial(27, 1, Blocks.stonebrick, 3, "stonebrick3");
CoverLib.addMaterial(28, 0, Blocks.planks, 1, "planks1");
CoverLib.addMaterial(29, 0, Blocks.planks, 2, "planks2");
CoverLib.addMaterial(30, 0, Blocks.planks, 3, "planks3");
CoverLib.addMaterial(31, 1, Blocks.sandstone, 1, "sandstone1");
for(int color = 0; color < 16; ++color) {
CoverLib.addMaterial(32 + color, 0, Blocks.wool, color, "wool." + CoreLib.rawColorNames[color]);
}
CoverLib.addMaterial(64, 1, Blocks.sandstone, 2, "sandstone2");
CoverLib.addMaterial(65, 0, Blocks.log, 3, "wood3");
}
public static void initAchievements() {
AchieveLib.registerAchievement("rpMakeAlloy", 0, 0, new ItemStack(blockAppliance, 1, 0), AchievementList.buildFurnace);
AchieveLib.registerAchievement("rpMakeSaw", 4, 0, new ItemStack(itemHandsawDiamond), AchievementList.diamonds);
AchieveLib.registerAchievement("rpIngotRed", 2, 2, itemIngotRed, "rpMakeAlloy");
AchieveLib.registerAchievement("rpIngotBlue", 2, 4, itemIngotBlue, "rpMakeAlloy");
AchieveLib.registerAchievement("rpIngotBrass", 2, 6, itemIngotBrass, "rpMakeAlloy");
AchieveLib.registerAchievement("rpAdvBench", -2, 0, new ItemStack(blockAppliance, 1, 3), AchievementList.buildWorkBench);
AchieveLib.addCraftingAchievement(new ItemStack(blockAppliance, 1, 0), "rpMakeAlloy");
AchieveLib.addCraftingAchievement(new ItemStack(blockAppliance, 1, 3), "rpAdvBench");
AchieveLib.addCraftingAchievement(new ItemStack(itemHandsawDiamond), "rpMakeSaw");
AchieveLib.addAlloyAchievement(itemIngotRed, "rpIngotRed");
AchieveLib.addAlloyAchievement(itemIngotBlue, "rpIngotBlue");
AchieveLib.addAlloyAchievement(itemIngotBrass, "rpIngotBrass");
AchievementPage.registerAchievementPage(AchieveLib.achievepage);
}
public static void initBlocks() {
blockMultiblock = new BlockMultiblock();
GameRegistry.registerBlock(blockMultiblock, "multiblock");
GameRegistry.registerTileEntity(TileMultiblock.class, "RPMulti");
blockAppliance = new BlockAppliance();
GameRegistry.registerBlock(blockAppliance, ItemExtended.class, "appliance");
GameRegistry.registerTileEntity(TileAlloyFurnace.class, "RPAFurnace");
blockAppliance.addTileEntityMapping(0, TileAlloyFurnace::new);
blockAppliance.setBlockName(0, "rpafurnace");
GameRegistry.addRecipe(new ItemStack(blockAppliance, 1, 0), new Object[]{"BBB", "B B", "BBB", 'B', Blocks.brick_block});
GameRegistry.registerTileEntity(TileAdvBench.class, "RPAdvBench");
blockAppliance.addTileEntityMapping(3, TileAdvBench::new);
blockAppliance.setBlockName(3, "rpabench");
CraftLib.addOreRecipe(
new ItemStack(blockAppliance, 1, 3), "SSS", "WTW", "WCW", 'S', Blocks.stone, 'W', "plankWood", 'T', Blocks.crafting_table, 'C', Blocks.chest
);
itemHandsawIron = new ItemHandsaw(0);
itemHandsawIron.setUnlocalizedName("handsawIron");
itemHandsawIron.setTextureName("rpworld:handsawIron");
itemHandsawIron.setMaxDamage(320);
GameRegistry.registerItem(itemHandsawIron, "ironHandshaw");
itemHandsawDiamond = new ItemHandsaw(2);
itemHandsawDiamond.setUnlocalizedName("handsawDiamond");
itemHandsawDiamond.setTextureName("rpworld:handsawDiamond");
itemHandsawDiamond.setMaxDamage(1280);
GameRegistry.registerItem(itemHandsawDiamond, "diamondHandshaw");
GameRegistry.addRecipe(new ItemStack(itemHandsawIron, 1), new Object[]{"WWW", " II", " II", 'I', Items.iron_ingot, 'W', Items.stick});
GameRegistry.addRecipe(
new ItemStack(itemHandsawDiamond, 1), new Object[]{"WWW", " II", " DD", 'I', Items.iron_ingot, 'D', Items.diamond, 'W', Items.stick}
);
GameRegistry.addShapelessRecipe(CoreLib.copyStack(itemWaferSilicon, 16), new Object[]{itemBouleSilicon, new ItemStack(itemHandsawDiamond, 1, 32767)});
itemScrewdriver = new ItemScrewdriver();
GameRegistry.addRecipe(new ItemStack(itemScrewdriver, 1), new Object[]{"I ", " W", 'I', Items.iron_ingot, 'W', Items.stick});
GameRegistry.registerItem(itemScrewdriver, "screwdriver");
GameRegistry.addRecipe(
new ItemStack(itemDrawplateDiamond, 1),
new Object[]{" I ", "IDI", " I ", 'I', new ItemStack(blockMicro, 1, 5649), 'D', new ItemStack(blockMicro, 1, 4115)}
);
GameRegistry.addShapelessRecipe(itemFineIron, new Object[]{Items.iron_ingot, new ItemStack(itemDrawplateDiamond, 1, 32767)});
CraftLib.addShapelessOreRecipe(itemFineCopper, "ingotCopper", new ItemStack(itemDrawplateDiamond, 1, 32767));
GameRegistry.addRecipe(CoreLib.copyStack(itemNuggetIron, 9), new Object[]{"I", 'I', Items.iron_ingot});
CraftLib.addOreRecipe(CoreLib.copyStack(itemNuggetCopper, 9), "I", 'I', "ingotCopper");
CraftLib.addOreRecipe(CoreLib.copyStack(itemNuggetTin, 9), "I", 'I', "ingotTin");
CraftLib.addOreRecipe(CoreLib.copyStack(itemNuggetSilver, 9), "I", 'I', "ingotSilver");
CraftLib.addOreRecipe(CoreLib.copyStack(itemNuggetTungsten, 9), "I", 'I', "ingotTungsten");
GameRegistry.addRecipe(new ItemStack(Items.iron_ingot, 1, 0), new Object[]{"III", "III", "III", 'I', itemNuggetIron});
GameRegistry.addRecipe(itemIngotSilver, new Object[]{"III", "III", "III", 'I', itemNuggetSilver});
GameRegistry.addRecipe(itemIngotTin, new Object[]{"III", "III", "III", 'I', itemNuggetTin});
GameRegistry.addRecipe(itemIngotCopper, new Object[]{"III", "III", "III", 'I', itemNuggetCopper});
GameRegistry.addRecipe(itemIngotTungsten, new Object[]{"III", "III", "III", 'I', itemNuggetTungsten});
GameRegistry.addRecipe(itemCanvas, new Object[]{"SSS", "SWS", "SSS", 'S', Items.string, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(Items.diamond, 2), new Object[]{"D", 'D', new ItemStack(blockMicro, 1, 4115)});
GameRegistry.addRecipe(new ItemStack(Items.diamond, 1), new Object[]{"D", 'D', new ItemStack(blockMicro, 1, 19)});
GameRegistry.addRecipe(new ItemStack(Items.iron_ingot, 2), new Object[]{"I", 'I', new ItemStack(blockMicro, 1, 4113)});
GameRegistry.addRecipe(new ItemStack(Items.iron_ingot, 1), new Object[]{"I", 'I', new ItemStack(blockMicro, 1, 17)});
}
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (FMLCommonHandler.instance().getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(instance);
}
}
@EventHandler
public void load(FMLInitializationEvent event) {
initBaseItems();
initAlloys();
initIndigo();
initMicroblocks();
initCoverMaterials();
initBlocks();
initAchievements();
CraftingManager.getInstance().getRecipeList().add(new RecipeBag());
if (FMLCommonHandler.instance().getSide().isClient()) {
this.registerRenderers();
}
NetworkRegistry.INSTANCE.registerGuiHandler(instance, instance);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLib.setRenderer(blockAppliance, 0, RenderAlloyFurnace::new);
RenderLib.setRenderer(blockAppliance, 3, RenderAdvBench::new);
ClientRegistry.bindTileEntitySpecialRenderer(TileAlloyFurnace.class, new RenderAlloyFurnace(blockAppliance));
ClientRegistry.bindTileEntitySpecialRenderer(TileAdvBench.class, new RenderAdvBench(blockAppliance));
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTextureStitch(Pre evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
projectTableTop = map.registerIcon("rpbase:projectTableTop");
projectTableBottom = map.registerIcon("rpbase:projectTableBottom");
projectTableFront = map.registerIcon("rpbase:projectTableFront");
projectTableSide = map.registerIcon("rpbase:projectTableSide");
alloyFurnaceVert = map.registerIcon("rpbase:alloyFurnaceVert");
alloyFurnaceSide = map.registerIcon("rpbase:alloyFurnaceSide");
alloyFurnaceFront = map.registerIcon("rpbase:alloyFurnaceFront");
alloyFurnaceFrontOn = map.registerIcon("rpbase:alloyFurnaceFrontOn");
}
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID) {
case 1:
return new GuiAlloyFurnace(player.inventory, CoreLib.getGuiTileEntity(world, x, y, z, TileAlloyFurnace.class));
case 2:
return new GuiAdvBench(player.inventory, CoreLib.getGuiTileEntity(world, x, y, z, TileAdvBench.class));
case 3:
return new GuiBusId(player.inventory, new IRedbusConnectable.Dummy(), CoreLib.getGuiTileEntity(world, x, y, z, TileEntity.class));
case 4:
return new GuiBag(player.inventory, new InventoryBasic("", true, 27));
default:
return null;
}
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID) {
case 1:
return new ContainerAlloyFurnace(player.inventory, CoreLib.getTileEntity(world, x, y, z, TileAlloyFurnace.class));
case 2:
return new ContainerAdvBench(player.inventory, CoreLib.getTileEntity(world, x, y, z, TileAdvBench.class));
case 3:
return new ContainerBusId(player.inventory, CoreLib.getTileEntity(world, x, y, z, IRedbusConnectable.class));
case 4:
ItemStack heldItem = player.getHeldItem();
return new ContainerBag(player.inventory, ItemBag.getBagInventory(heldItem, player), heldItem);
default:
return null;
}
}
}

View File

@ -0,0 +1,129 @@
package com.eloraam.redpower;
import com.eloraam.redpower.compat.BlockMachineCompat;
import com.eloraam.redpower.compat.ItemMachineCompat;
import com.eloraam.redpower.compat.RenderBlueEngine;
import com.eloraam.redpower.compat.TileBlueEngine;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CraftLib;
import com.eloraam.redpower.core.ItemParts;
import com.eloraam.redpower.core.RenderLib;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
//import ic2.api.recipe.ICraftingRecipeManager;
//import ic2.api.recipe.Recipes;
//import ic2.core.Ic2Items;
//import ic2.core.block.machine.tileentity.TileEntityMacerator;
//import ic2.core.block.machine.tileentity.TileEntityRotary;
//import ic2.core.block.machine.tileentity.TileEntitySingularity;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@Mod(
modid = "RedPowerCompat",
name = "RedPower Compat",
version = "2.0pr6",
dependencies = "required-after:RedPowerBase;required-after:RedPowerMachine;required-after:RedPowerWorld;after:IC2;after:Waila"
)
public class RedPowerCompat implements IGuiHandler {
@Instance("RedPowerCompat")
public static RedPowerCompat instance;
public static BlockMachineCompat blockMachineCompat;
public static ItemParts itemCompatParts;
public static ItemStack itemGearBrass;
public static ItemStack itemDenseTungstenPlate;
static boolean ic2reworked;
static boolean waila;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
for(ModContainer modContainer : Loader.instance().getActiveModList()) {
if (modContainer.getName().equalsIgnoreCase("Industrial Craft Reworked")) {
ic2reworked = true;
break;
}
}
waila = Loader.isModLoaded("Waila");
}
@EventHandler
public void load(FMLInitializationEvent event) {
this.setupBlocks();
if (event.getSide().isClient()) {
this.registerRenderers();
}
NetworkRegistry.INSTANCE.registerGuiHandler(instance, instance);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLib.setRenderer(blockMachineCompat, 0, RenderBlueEngine::new);
ClientRegistry.bindTileEntitySpecialRenderer(TileBlueEngine.class, new RenderBlueEngine(blockMachineCompat));
}
private void setupBlocks() {
GameRegistry.registerTileEntity(TileBlueEngine.class, "RPBTEngine");
blockMachineCompat = new BlockMachineCompat();
GameRegistry.registerBlock(blockMachineCompat, ItemMachineCompat.class, "compat");
blockMachineCompat.setBlockName(0, "rpbtengine");
blockMachineCompat.addTileEntityMapping(0, TileBlueEngine::new);
itemCompatParts = new ItemParts();
itemCompatParts.addItem(0, "rpcompat:gear", "item.rpbgear");
itemCompatParts.addItem(1, "rpcompat:densePlateTungsten", "item.densePlateTungsten");
itemCompatParts.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemCompatParts, "parts");
itemGearBrass = new ItemStack(itemCompatParts, 1, 0);
itemDenseTungstenPlate = new ItemStack(itemCompatParts, 1, 1);
CraftLib.addOreRecipe(new ItemStack(itemCompatParts, 1, 0), " B ", "BIB", " B ", 'B', "ingotBrass", 'I', new ItemStack(RedPowerBase.blockMicro, 1, 5649));
CraftLib.addOreRecipe(
new ItemStack(blockMachineCompat, 1, 0), "BBB", " G ", "ZMZ", 'B', "ingotBrass", 'G', Blocks.glass, 'Z', itemGearBrass, 'M', RedPowerBase.itemMotor
);
//TODO: IC2 Classic compat
/*if (ic2reworked) {
TileEntityRotary.addRecipe(new ItemStack(RedPowerWorld.blockOres, 1, 6), new ItemStack(RedPowerBase.itemResource, 2, 8));
TileEntityMacerator.addRecipe(new ItemStack(RedPowerWorld.blockOres, 1, 3), new ItemStack(RedPowerBase.itemResource, 2, 9));
TileEntityRotary.addRecipe(RedPowerBase.itemIngotTungsten, new ItemStack(RedPowerBase.itemResource, 1, 8));
TileEntitySingularity.addRecipe(CoreLib.copyStack(RedPowerBase.itemIngotTungsten, 8), itemDenseTungstenPlate);
ICraftingRecipeManager advRecipes = Recipes.advRecipes;
advRecipes.addRecipe(RedPowerBase.itemRuby, new Object[]{" MM", "MMM", "MM ", 'M', Ic2Items.matter, true});
advRecipes.addRecipe(RedPowerBase.itemSapphire, new Object[]{"MM ", "MMM", " MM", 'M', Ic2Items.matter, true});
advRecipes.addRecipe(RedPowerBase.itemGreenSapphire, new Object[]{" MM", "MMM", " MM", 'M', Ic2Items.matter, true});
advRecipes.addRecipe(RedPowerBase.itemNikolite, new Object[]{"MMM", " M ", 'M', Ic2Items.matter, true});
advRecipes.addRecipe(RedPowerBase.itemDustSilver, new Object[]{" M", " MM", " M", 'M', Ic2Items.matter, true});
advRecipes.addRecipe(RedPowerBase.itemDustTungsten, new Object[]{"MMM", "MDM", "MMM", 'M', Ic2Items.matter, 'D', Items.diamond, true});
advRecipes.addRecipe(RedPowerWorld.itemMarble, new Object[]{"M ", " ", " ", 'M', Ic2Items.matter, true});
advRecipes.addRecipe(RedPowerWorld.itemBasalt, new Object[]{" M", " ", " ", 'M', Ic2Items.matter, true});
}*/
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
}

View File

@ -0,0 +1,307 @@
package com.eloraam.redpower;
import com.eloraam.redpower.control.BlockPeripheral;
import com.eloraam.redpower.control.ContainerCPU;
import com.eloraam.redpower.control.ContainerDisplay;
import com.eloraam.redpower.control.GuiCPU;
import com.eloraam.redpower.control.GuiDisplay;
import com.eloraam.redpower.control.ItemBackplane;
import com.eloraam.redpower.control.ItemDisk;
import com.eloraam.redpower.control.MicroPlacementRibbon;
import com.eloraam.redpower.control.RenderBackplane;
import com.eloraam.redpower.control.RenderCPU;
import com.eloraam.redpower.control.RenderDiskDrive;
import com.eloraam.redpower.control.RenderDisplay;
import com.eloraam.redpower.control.RenderIOExpander;
import com.eloraam.redpower.control.RenderRibbon;
import com.eloraam.redpower.control.TileBackplane;
import com.eloraam.redpower.control.TileCPU;
import com.eloraam.redpower.control.TileDiskDrive;
import com.eloraam.redpower.control.TileDisplay;
import com.eloraam.redpower.control.TileIOExpander;
import com.eloraam.redpower.control.TileRAM;
import com.eloraam.redpower.control.TileRibbon;
import com.eloraam.redpower.core.BlockExtended;
import com.eloraam.redpower.core.BlockMultipart;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CraftLib;
import com.eloraam.redpower.core.CreativeExtraTabs;
import com.eloraam.redpower.core.ItemExtended;
import com.eloraam.redpower.core.RenderLib;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent.Pre;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
@Mod(
modid = "RedPowerControl",
name = "RedPower Control",
version = "2.0pr6",
dependencies = "required-after:RedPowerBase"
)
public class RedPowerControl implements IGuiHandler {
@Instance("RedPowerControl")
public static RedPowerControl instance;
public static BlockExtended blockBackplane;
public static BlockExtended blockPeripheral;
public static BlockExtended blockFlatPeripheral;
public static ItemDisk itemDisk;
public static IIcon ribbonTop;
public static IIcon ribbonFace;
@SideOnly(Side.CLIENT)
public static IIcon backplaneTop;
@SideOnly(Side.CLIENT)
public static IIcon backplaneFace;
@SideOnly(Side.CLIENT)
public static IIcon backplaneSide;
@SideOnly(Side.CLIENT)
public static IIcon ram8kTop;
@SideOnly(Side.CLIENT)
public static IIcon ram8kFace;
@SideOnly(Side.CLIENT)
public static IIcon ram8kSide;
@SideOnly(Side.CLIENT)
public static IIcon peripheralBottom;
@SideOnly(Side.CLIENT)
public static IIcon peripheralTop;
@SideOnly(Side.CLIENT)
public static IIcon peripheralSide;
@SideOnly(Side.CLIENT)
public static IIcon peripheralBack;
@SideOnly(Side.CLIENT)
public static IIcon cpuFront;
@SideOnly(Side.CLIENT)
public static IIcon displayFront;
@SideOnly(Side.CLIENT)
public static IIcon diskDriveSide;
@SideOnly(Side.CLIENT)
public static IIcon diskDriveTop;
@SideOnly(Side.CLIENT)
public static IIcon diskDriveFront;
@SideOnly(Side.CLIENT)
public static IIcon diskDriveFrontFull;
@SideOnly(Side.CLIENT)
public static IIcon diskDriveFrontOn;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (FMLCommonHandler.instance().getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(instance);
}
}
@EventHandler
public void load(FMLInitializationEvent event) {
setupBlocks();
if (FMLCommonHandler.instance().getSide().isClient()) {
this.registerRenderers();
}
NetworkRegistry.INSTANCE.registerGuiHandler(instance, instance);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
private static void setupBlocks() {
blockBackplane = new BlockMultipart(CoreLib.materialRedpower);
GameRegistry.registerBlock(blockBackplane, ItemBackplane.class, "backplane");
blockBackplane.setCreativeTab(CreativeExtraTabs.tabMachine);
blockBackplane.setHardness(1.0F);
blockBackplane.setBlockName(0, "rpbackplane");
blockBackplane.setBlockName(1, "rpram");
blockPeripheral = new BlockPeripheral();
GameRegistry.registerBlock(blockPeripheral, ItemExtended.class, "peripheral");
blockPeripheral.setHardness(1.0F);
blockPeripheral.setBlockName(0, "rpdisplay");
blockPeripheral.setBlockName(1, "rpcpu");
blockPeripheral.setBlockName(2, "rpdiskdrive");
blockFlatPeripheral = new BlockMultipart(Material.rock);
blockFlatPeripheral.setCreativeTab(CreativeExtraTabs.tabMachine);
GameRegistry.registerBlock(blockFlatPeripheral, ItemExtended.class, "peripheralFlat");
blockFlatPeripheral.setHardness(1.0F);
blockFlatPeripheral.setBlockName(0, "rpioexp");
GameRegistry.registerTileEntity(TileBackplane.class, "RPConBP");
blockBackplane.addTileEntityMapping(0, TileBackplane::new);
GameRegistry.registerTileEntity(TileRAM.class, "RPConRAM");
blockBackplane.addTileEntityMapping(1, TileRAM::new);
GameRegistry.registerTileEntity(TileDisplay.class, "RPConDisp");
blockPeripheral.addTileEntityMapping(0, TileDisplay::new);
GameRegistry.registerTileEntity(TileDiskDrive.class, "RPConDDrv");
blockPeripheral.addTileEntityMapping(2, TileDiskDrive::new);
GameRegistry.registerTileEntity(TileCPU.class, "RPConCPU");
blockPeripheral.addTileEntityMapping(1, TileCPU::new);
GameRegistry.registerTileEntity(TileIOExpander.class, "RPConIOX");
blockFlatPeripheral.addTileEntityMapping(0, TileIOExpander::new);
GameRegistry.registerTileEntity(TileRibbon.class, "RPConRibbon");
RedPowerBase.blockMicro.addTileEntityMapping(12, TileRibbon::new);
MicroPlacementRibbon imp = new MicroPlacementRibbon();
RedPowerBase.blockMicro.registerPlacement(12, imp);
itemDisk = new ItemDisk();
itemDisk.setCreativeTab(CreativeExtraTabs.tabMachine);
CraftLib.addOreRecipe(new ItemStack(itemDisk, 1), "WWW", "W W", "WIW", 'I', Items.iron_ingot, 'W', "plankWood");
GameRegistry.addShapelessRecipe(new ItemStack(itemDisk, 1, 1), new Object[]{new ItemStack(itemDisk, 1, 0), Items.redstone});
GameRegistry.registerItem(itemDisk, "diskette");
GameRegistry.addShapelessRecipe(new ItemStack(itemDisk, 1, 2), new Object[]{new ItemStack(itemDisk, 1, 1), Items.redstone});
GameRegistry.addRecipe(
new ItemStack(blockBackplane, 1, 0), new Object[]{"ICI", "IGI", "ICI", 'C', RedPowerBase.itemFineCopper, 'I', Blocks.iron_bars, 'G', Items.gold_ingot}
);
GameRegistry.addRecipe(
new ItemStack(blockBackplane, 1, 1), new Object[]{"IRI", "RDR", "IRI", 'I', Blocks.iron_bars, 'R', RedPowerBase.itemWaferRed, 'D', Items.diamond}
);
CraftLib.addOreRecipe(
new ItemStack(blockPeripheral, 1, 0),
"GWW",
"GPR",
"GBW",
'P',
new ItemStack(RedPowerBase.itemLumar, 1, 5),
'G',
Blocks.glass,
'W',
"plankWood",
'R',
RedPowerBase.itemWaferRed,
'B',
new ItemStack(RedPowerBase.blockMicro, 1, 3072)
);
CraftLib.addOreRecipe(
new ItemStack(blockPeripheral, 1, 1),
"WWW",
"RDR",
"WBW",
'W',
"plankWood",
'D',
Blocks.diamond_block,
'R',
RedPowerBase.itemWaferRed,
'B',
new ItemStack(RedPowerBase.blockMicro, 1, 3072)
);
CraftLib.addOreRecipe(
new ItemStack(blockPeripheral, 1, 2),
"WWW",
"WMR",
"WBW",
'G',
Blocks.glass,
'W',
"plankWood",
'M',
RedPowerBase.itemMotor,
'R',
RedPowerBase.itemWaferRed,
'B',
new ItemStack(RedPowerBase.blockMicro, 1, 3072)
);
CraftLib.addOreRecipe(
new ItemStack(blockFlatPeripheral, 1, 0),
"WCW",
"WRW",
"WBW",
'W',
"plankWood",
'R',
RedPowerBase.itemWaferRed,
'C',
new ItemStack(RedPowerBase.blockMicro, 1, 768),
'B',
new ItemStack(RedPowerBase.blockMicro, 1, 3072)
);
GameRegistry.addRecipe(new ItemStack(RedPowerBase.blockMicro, 8, 3072), new Object[]{"C", "C", "C", 'C', RedPowerBase.itemFineCopper});
ChestGenHooks.addItem("dungeonChest", new WeightedRandomChestContent(new ItemStack(itemDisk, 1, 1), 0, 1, 1));
ChestGenHooks.addItem("dungeonChest", new WeightedRandomChestContent(new ItemStack(itemDisk, 1, 2), 0, 1, 1));
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLib.setRenderer(blockBackplane, 0, RenderBackplane::new);
RenderLib.setRenderer(blockBackplane, 1, RenderBackplane::new);
RenderLib.setRenderer(blockPeripheral, 0, RenderDisplay::new);
RenderLib.setRenderer(blockPeripheral, 1, RenderCPU::new);
RenderLib.setRenderer(blockPeripheral, 2, RenderDiskDrive::new);
RenderLib.setRenderer(blockFlatPeripheral, 0, RenderIOExpander::new);
RenderLib.setHighRenderer(RedPowerBase.blockMicro, 12, RenderRibbon::new);
ClientRegistry.bindTileEntitySpecialRenderer(TileBackplane.class, new RenderBackplane(blockBackplane));
ClientRegistry.bindTileEntitySpecialRenderer(TileRibbon.class, new RenderRibbon(RedPowerBase.blockMicro));
ClientRegistry.bindTileEntitySpecialRenderer(TileIOExpander.class, new RenderIOExpander(blockPeripheral));
ClientRegistry.bindTileEntitySpecialRenderer(TileCPU.class, new RenderCPU(blockPeripheral));
ClientRegistry.bindTileEntitySpecialRenderer(TileDiskDrive.class, new RenderDiskDrive(blockPeripheral));
ClientRegistry.bindTileEntitySpecialRenderer(TileDisplay.class, new RenderDisplay(blockPeripheral));
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTextureStitch(Pre evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
ribbonTop = map.registerIcon("rpcontrol:ribbonTop");
ribbonFace = map.registerIcon("rpcontrol:ribbonFace");
backplaneTop = map.registerIcon("rpcontrol:backplaneTop");
backplaneFace = map.registerIcon("rpcontrol:backplaneFace");
backplaneSide = map.registerIcon("rpcontrol:backplaneSide");
ram8kTop = map.registerIcon("rpcontrol:ram8kTop");
ram8kFace = map.registerIcon("rpcontrol:ram8kFace");
ram8kSide = map.registerIcon("rpcontrol:ram8kSide");
peripheralBottom = map.registerIcon("rpcontrol:peripheralBottom");
peripheralTop = map.registerIcon("rpcontrol:peripheralTop");
peripheralSide = map.registerIcon("rpcontrol:peripheralSide");
peripheralBack = map.registerIcon("rpcontrol:peripheralBack");
cpuFront = map.registerIcon("rpcontrol:cpuFront");
displayFront = map.registerIcon("rpcontrol:displayFront");
diskDriveSide = map.registerIcon("rpcontrol:diskDriveSide");
diskDriveTop = map.registerIcon("rpcontrol:diskDriveTop");
diskDriveFront = map.registerIcon("rpcontrol:diskDriveFront");
diskDriveFrontFull = map.registerIcon("rpcontrol:diskDriveFrontFull");
diskDriveFrontOn = map.registerIcon("rpcontrol:diskDriveFrontOn");
}
}
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
switch(id) {
case 1:
return new GuiDisplay(player.inventory, CoreLib.getGuiTileEntity(world, x, y, z, TileDisplay.class));
case 2:
return new GuiCPU(player.inventory, CoreLib.getGuiTileEntity(world, x, y, z, TileCPU.class));
default:
return null;
}
}
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
switch(id) {
case 1:
return new ContainerDisplay(player.inventory, CoreLib.getTileEntity(world, x, y, z, TileDisplay.class));
case 2:
return new ContainerCPU(player.inventory, CoreLib.getTileEntity(world, x, y, z, TileCPU.class));
default:
return null;
}
}
}

View File

@ -0,0 +1,108 @@
package com.eloraam.redpower;
import com.eloraam.redpower.core.Config;
import com.eloraam.redpower.core.CoreEvents;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CoverRecipe;
import com.eloraam.redpower.core.PacketHandler;
import com.eloraam.redpower.core.RenderHighlight;
import com.eloraam.redpower.core.RenderSimpleCovered;
import com.eloraam.redpower.core.TileCovered;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.File;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent.Pre;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
@Mod(
modid = "RedPowerCore",
name = "RedPower Core",
version = "2.0pr6"
)
public class RedPowerCore {
@Instance("RedPowerCore")
public static RedPowerCore instance;
public static PacketHandler packetHandler = new PacketHandler();
public static int customBlockModel = -1;
public static int nullBlockModel = -1;
@SideOnly(Side.CLIENT)
public static IIcon missing;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
Config.loadConfig();
CoreLib.readOres();
MinecraftForge.EVENT_BUS.register(new CoreEvents());
if (FMLCommonHandler.instance().getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(instance);
}
}
@EventHandler
public void load(FMLInitializationEvent event) {
packetHandler.init();
if (FMLCommonHandler.instance().getSide().isClient()) {
this.setupRenderers();
}
CraftingManager.getInstance().getRecipeList().add(new CoverRecipe());
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
Config.saveConfig();
}
public static File getSaveDir(World world) {
return DimensionManager.getCurrentSaveRootDirectory();
}
public static void sendPacketToServer(IMessage msg) {
packetHandler.sendToServer(msg);
}
public static void sendPacketToCrafting(ICrafting icr, IMessage msg) {
if (icr instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP)icr;
packetHandler.sendTo(msg, player);
}
}
@SideOnly(Side.CLIENT)
public void setupRenderers() {
customBlockModel = RenderingRegistry.getNextAvailableRenderId();
nullBlockModel = RenderingRegistry.getNextAvailableRenderId();
MinecraftForge.EVENT_BUS.register(new RenderHighlight());
ClientRegistry.bindTileEntitySpecialRenderer(TileCovered.class, new RenderSimpleCovered());
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTextureStitch(Pre evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
missing = map.registerIcon("rpcore:missing");
}
}
}

View File

@ -0,0 +1,216 @@
package com.eloraam.redpower;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.RenderLib;
import com.eloraam.redpower.lighting.BlockLamp;
import com.eloraam.redpower.lighting.BlockShapedLamp;
import com.eloraam.redpower.lighting.ItemLamp;
import com.eloraam.redpower.lighting.RenderLamp;
import com.eloraam.redpower.lighting.RenderShapedLamp;
import com.eloraam.redpower.lighting.TileLamp;
import com.eloraam.redpower.lighting.TileShapedLamp;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent.Pre;
import net.minecraftforge.common.MinecraftForge;
@Mod(
modid = "RedPowerLighting",
name = "RedPower Lighting",
version = "2.0pr6",
dependencies = "required-after:RedPowerBase"
)
public class RedPowerLighting {
@Instance("RedPowerLighting")
public static RedPowerLighting instance;
public static BlockLamp blockLamp;
public static BlockShapedLamp blockShapedLamp;
public static CreativeTabs tabLamp = new CreativeTabs(CreativeTabs.getNextID(), "RPLights") {
public ItemStack getIconItemStack() {
return new ItemStack(RedPowerLighting.blockLamp, 1, 16);
}
public Item getTabIconItem() {
return null;
}
};
public static IIcon[] lampOff;
public static IIcon[] lampOn;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (FMLCommonHandler.instance().getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(instance);
}
}
@EventHandler
public void load(FMLInitializationEvent event) {
setupLighting();
if (FMLCommonHandler.instance().getSide().isClient()) {
this.registerRenderers();
}
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
public static void setupLighting() {
blockLamp = new BlockLamp();
blockLamp.setBlockName("rplamp");
GameRegistry.registerBlock(blockLamp, ItemLamp.class, "lampo");
GameRegistry.registerTileEntity(TileLamp.class, "RPLamp");
blockLamp.addTileEntityMapping(0, TileLamp::new);
for(int color = 0; color < 16; ++color) {
String nm = "rplamp." + CoreLib.rawColorNames[color];
blockLamp.setBlockName(color, nm);
GameRegistry.addRecipe(
new ItemStack(blockLamp, 1, color),
new Object[]{"GLG", "GLG", "GRG", 'G', Blocks.glass_pane, 'L', new ItemStack(RedPowerBase.itemLumar, 1, color), 'R', Items.redstone}
);
}
for(int color = 0; color < 16; ++color) {
String nm = "rpilamp." + CoreLib.rawColorNames[color];
blockLamp.setBlockName(color + 16, nm);
GameRegistry.addRecipe(
new ItemStack(blockLamp, 1, 16 + color),
new Object[]{"GLG", "GLG", "GRG", 'G', Blocks.glass_pane, 'L', new ItemStack(RedPowerBase.itemLumar, 1, color), 'R', Blocks.redstone_torch}
);
}
blockShapedLamp = new BlockShapedLamp();
GameRegistry.registerBlock(blockShapedLamp, ItemLamp.class, "shlamp");
GameRegistry.registerTileEntity(TileShapedLamp.class, "RPShLamp");
blockShapedLamp.addTileEntityMapping(0, TileShapedLamp::new);
for(int color = 0; color < 16; ++color) {
String nm = "rpshlamp." + CoreLib.rawColorNames[color];
blockShapedLamp.setBlockName(color, nm);
GameRegistry.addRecipe(
new ItemStack(blockShapedLamp, 1, color),
new Object[]{
"GLG", "GLG", "SRS", 'G', Blocks.glass_pane, 'L', new ItemStack(RedPowerBase.itemLumar, 1, color), 'R', Items.redstone, 'S', Blocks.stone_slab
}
);
}
for(int color = 0; color < 16; ++color) {
String nm = "rpishlamp." + CoreLib.rawColorNames[color];
blockShapedLamp.setBlockName(color + 16, nm);
GameRegistry.addRecipe(
new ItemStack(blockShapedLamp, 1, 16 + color),
new Object[]{
"GLG",
"GLG",
"SRS",
'G',
Blocks.glass_pane,
'L',
new ItemStack(RedPowerBase.itemLumar, 1, color),
'R',
Blocks.redstone_torch,
'S',
new ItemStack(Blocks.stone_slab, 1, 0)
}
);
}
for(int color = 0; color < 16; ++color) {
String nm = "rpshlamp2." + CoreLib.rawColorNames[color];
blockShapedLamp.setBlockName(color + 32, nm);
GameRegistry.addRecipe(
new ItemStack(blockShapedLamp, 1, 32 + color),
new Object[]{
"ILI",
"GLG",
"SRS",
'G',
Blocks.glass_pane,
'L',
new ItemStack(RedPowerBase.itemLumar, 1, color),
'R',
Items.redstone,
'I',
Blocks.iron_bars,
'S',
new ItemStack(Blocks.stone_slab, 1, 0)
}
);
}
for(int color = 0; color < 16; ++color) {
String nm = "rpishlamp2." + CoreLib.rawColorNames[color];
blockShapedLamp.setBlockName(color + 48, nm);
GameRegistry.addRecipe(
new ItemStack(blockShapedLamp, 1, 48 + color),
new Object[]{
"ILI",
"GLG",
"SRS",
'G',
Blocks.glass_pane,
'L',
new ItemStack(RedPowerBase.itemLumar, 1, color),
'R',
Blocks.redstone_torch,
'I',
Blocks.iron_bars,
'S',
Blocks.stone_slab
}
);
}
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLib.setDefaultRenderer(blockLamp, 10, RenderLamp::new);
RenderLib.setDefaultRenderer(blockShapedLamp, 10, RenderShapedLamp::new);
ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class, new RenderLamp(blockLamp));
ClientRegistry.bindTileEntitySpecialRenderer(TileShapedLamp.class, new RenderShapedLamp(blockShapedLamp));
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTextureStitch(Pre evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
if (lampOff == null) {
lampOff = new IIcon[16];
}
if (lampOn == null) {
lampOn = new IIcon[16];
}
for(int i = 0; i < 16; ++i) {
lampOff[i] = map.registerIcon("rplighting:lampOff/" + i);
lampOn[i] = map.registerIcon("rplighting:lampOn/" + i);
}
}
}
}

View File

@ -0,0 +1,313 @@
package com.eloraam.redpower;
import com.eloraam.redpower.core.Config;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.ItemParts;
import com.eloraam.redpower.core.RenderLib;
import com.eloraam.redpower.logic.BlockLogic;
import com.eloraam.redpower.logic.ContainerCounter;
import com.eloraam.redpower.logic.ContainerTimer;
import com.eloraam.redpower.logic.GuiCounter;
import com.eloraam.redpower.logic.GuiTimer;
import com.eloraam.redpower.logic.ItemLogic;
import com.eloraam.redpower.logic.RenderLogicAdv;
import com.eloraam.redpower.logic.RenderLogicArray;
import com.eloraam.redpower.logic.RenderLogicPointer;
import com.eloraam.redpower.logic.RenderLogicSimple;
import com.eloraam.redpower.logic.RenderLogicStorage;
import com.eloraam.redpower.logic.TileLogicAdv;
import com.eloraam.redpower.logic.TileLogicArray;
import com.eloraam.redpower.logic.TileLogicPointer;
import com.eloraam.redpower.logic.TileLogicSimple;
import com.eloraam.redpower.logic.TileLogicStorage;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent.Post;
import net.minecraftforge.client.event.TextureStitchEvent.Pre;
import net.minecraftforge.common.MinecraftForge;
@Mod(
modid = "RedPowerLogic",
name = "RedPower Logic",
version = "2.0pr6",
dependencies = "required-after:RedPowerBase"
)
public class RedPowerLogic implements IGuiHandler {
@Instance("RedPowerLogic")
public static RedPowerLogic instance;
public static BlockLogic blockLogic;
public static ItemParts itemParts;
public static ItemStack itemAnode;
public static ItemStack itemCathode;
public static ItemStack itemWire;
public static ItemStack itemWafer;
public static ItemStack itemPointer;
public static ItemStack itemPlate;
public static ItemStack itemWaferRedwire;
public static ItemStack itemChip;
public static ItemStack itemTaintedChip;
public static ItemStack itemWaferBundle;
public static boolean soundsEnabled;
@SideOnly(Side.CLIENT)
public static IIcon torch;
@SideOnly(Side.CLIENT)
public static IIcon torchOn;
@SideOnly(Side.CLIENT)
public static IIcon lever;
@SideOnly(Side.CLIENT)
public static IIcon cobblestone;
public static IIcon[] logicOne = new IIcon[232];
public static IIcon[] logicTwo = new IIcon[256];
public static IIcon[] logicSensor = new IIcon[23];
private static void setupLogic() {
GameRegistry.registerTileEntity(TileLogicSimple.class, "RPLgSmp");
GameRegistry.registerTileEntity(TileLogicArray.class, "RPLgAr");
GameRegistry.registerTileEntity(TileLogicStorage.class, "RPLgStor");
GameRegistry.registerTileEntity(TileLogicAdv.class, "RPLgAdv");
GameRegistry.registerTileEntity(TileLogicPointer.class, "RPLgPtr");
itemParts = new ItemParts();
itemParts.addItem(0, "rplogic:wafer", "item.irwafer");
itemParts.addItem(1, "rplogic:wire", "item.irwire");
itemParts.addItem(2, "rplogic:anode", "item.iranode");
itemParts.addItem(3, "rplogic:cathode", "item.ircathode");
itemParts.addItem(4, "rplogic:pointer", "item.irpointer");
itemParts.addItem(5, "rplogic:redWire", "item.irredwire");
itemParts.addItem(6, "rplogic:plate", "item.irplate");
itemParts.addItem(7, "rplogic:chip", "item.irchip");
itemParts.addItem(8, "rplogic:tchip", "item.irtchip");
itemParts.addItem(9, "rplogic:bundle", "item.irbundle");
GameRegistry.registerItem(itemParts, "parts");
itemWafer = new ItemStack(itemParts, 1, 0);
itemWire = new ItemStack(itemParts, 1, 1);
itemAnode = new ItemStack(itemParts, 1, 2);
itemCathode = new ItemStack(itemParts, 1, 3);
itemPointer = new ItemStack(itemParts, 1, 4);
itemWaferRedwire = new ItemStack(itemParts, 1, 5);
itemPlate = new ItemStack(itemParts, 1, 6);
itemChip = new ItemStack(itemParts, 1, 7);
itemTaintedChip = new ItemStack(itemParts, 1, 8);
itemWaferBundle = new ItemStack(itemParts, 1, 9);
FurnaceRecipes.smelting().func_151393_a(Blocks.stone, new ItemStack(itemParts, 2, 0), 0.1F);
GameRegistry.addRecipe(itemWire, new Object[]{"R", "B", 'B', itemWafer, 'R', Items.redstone});
GameRegistry.addRecipe(new ItemStack(itemParts, 3, 2), new Object[]{" R ", "RRR", "BBB", 'B', itemWafer, 'R', Items.redstone});
GameRegistry.addRecipe(itemCathode, new Object[]{"T", "B", 'B', itemWafer, 'T', Blocks.redstone_torch});
GameRegistry.addRecipe(itemPointer, new Object[]{"S", "T", "B", 'B', itemWafer, 'S', Blocks.stone, 'T', Blocks.redstone_torch});
GameRegistry.addRecipe(itemWaferRedwire, new Object[]{"W", "B", 'B', itemWafer, 'W', new ItemStack(RedPowerBase.blockMicro, 1, 256)});
GameRegistry.addRecipe(itemPlate, new Object[]{" B ", "SRS", "BCB", 'B', itemWafer, 'C', itemCathode, 'R', RedPowerBase.itemIngotRed, 'S', Items.stick});
GameRegistry.addRecipe(CoreLib.copyStack(itemChip, 3), new Object[]{" R ", "BBB", 'B', itemWafer, 'R', RedPowerBase.itemWaferRed});
GameRegistry.addShapelessRecipe(CoreLib.copyStack(itemTaintedChip, 1), new Object[]{itemChip, Items.glowstone_dust});
GameRegistry.addRecipe(itemWaferBundle, new Object[]{"W", "B", 'B', itemWafer, 'W', new ItemStack(RedPowerBase.blockMicro, 1, 768)});
blockLogic = new BlockLogic();
GameRegistry.registerBlock(blockLogic, ItemLogic.class, "logic");
blockLogic.addTileEntityMapping(0, TileLogicPointer::new);
blockLogic.addTileEntityMapping(1, TileLogicSimple::new);
blockLogic.addTileEntityMapping(2, TileLogicArray::new);
blockLogic.addTileEntityMapping(3, TileLogicStorage::new);
blockLogic.addTileEntityMapping(4, TileLogicAdv::new);
blockLogic.setBlockName(0, "irtimer");
blockLogic.setBlockName(1, "irseq");
blockLogic.setBlockName(2, "irstate");
blockLogic.setBlockName(256, "irlatch");
blockLogic.setBlockName(257, "irnor");
blockLogic.setBlockName(258, "iror");
blockLogic.setBlockName(259, "irnand");
blockLogic.setBlockName(260, "irand");
blockLogic.setBlockName(261, "irxnor");
blockLogic.setBlockName(262, "irxor");
blockLogic.setBlockName(263, "irpulse");
blockLogic.setBlockName(264, "irtoggle");
blockLogic.setBlockName(265, "irnot");
blockLogic.setBlockName(266, "irbuf");
blockLogic.setBlockName(267, "irmux");
blockLogic.setBlockName(268, "irrepeater");
blockLogic.setBlockName(269, "irsync");
blockLogic.setBlockName(270, "irrand");
blockLogic.setBlockName(271, "irdlatch");
blockLogic.setBlockName(272, "rplightsensor");
blockLogic.setBlockName(512, "rpanc");
blockLogic.setBlockName(513, "rpainv");
blockLogic.setBlockName(514, "rpaninv");
blockLogic.setBlockName(768, "ircounter");
blockLogic.setBlockName(1024, "irbusxcvr");
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 0), new Object[]{"BWB", "WPW", "ACA", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode, 'P', itemPointer}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 1), new Object[]{"BCB", "CPC", "BCB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode, 'P', itemPointer}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 2),
new Object[]{"BAC", "WSP", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode, 'P', itemPointer, 'S', itemChip}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 256), new Object[]{"WWA", "CBC", "AWW", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 257), new Object[]{"BAB", "WCW", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(new ItemStack(blockLogic, 1, 258), new Object[]{"BCB", "WCW", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode});
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 259), new Object[]{"AAA", "CCC", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 260), new Object[]{"ACA", "CCC", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 261), new Object[]{"ACA", "CAC", "WCW", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 262), new Object[]{"AWA", "CAC", "WCW", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 263), new Object[]{"ACA", "CAC", "WWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 264), new Object[]{"BCB", "WLW", "BCB", 'L', Blocks.lever, 'W', itemWire, 'B', itemWafer, 'C', itemCathode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 265), new Object[]{"BAB", "ACA", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 266), new Object[]{"ACA", "WCW", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 267), new Object[]{"ACA", "CBC", "ACW", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 268), new Object[]{"BCW", "BAW", "BWC", 'W', itemWire, 'B', itemWafer, 'A', itemAnode, 'C', itemCathode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 269), new Object[]{"WCW", "SAS", "WWW", 'W', itemWire, 'B', itemWafer, 'A', itemAnode, 'C', itemCathode, 'S', itemChip}
);
GameRegistry.addRecipe(new ItemStack(blockLogic, 1, 270), new Object[]{"BSB", "WWW", "SWS", 'W', itemWire, 'B', itemWafer, 'S', itemTaintedChip});
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 271), new Object[]{"ACW", "CCC", "CWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'A', itemAnode}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 272), new Object[]{"BWB", "BSB", "BBB", 'W', itemWire, 'B', itemWafer, 'S', RedPowerBase.itemWaferBlue}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 768), new Object[]{"BWB", "CPC", "BWB", 'W', itemWire, 'B', itemWafer, 'C', itemCathode, 'P', itemPointer}
);
GameRegistry.addRecipe(new ItemStack(blockLogic, 1, 512), new Object[]{"BRB", "RRR", "BRB", 'B', itemWafer, 'R', itemWaferRedwire});
GameRegistry.addRecipe(new ItemStack(blockLogic, 1, 513), new Object[]{"BRB", "RPR", "BRB", 'B', itemWafer, 'R', itemWaferRedwire, 'P', itemPlate});
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 514), new Object[]{"BRB", "RPR", "BRC", 'B', itemWafer, 'C', itemCathode, 'R', itemWaferRedwire, 'P', itemPlate}
);
GameRegistry.addRecipe(
new ItemStack(blockLogic, 1, 1024), new Object[]{"CCC", "WBW", "CCC", 'B', itemWafer, 'W', RedPowerBase.itemWaferRed, 'C', itemWaferBundle}
);
}
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (FMLCommonHandler.instance().getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(instance);
}
}
@EventHandler
public void load(FMLInitializationEvent event) {
soundsEnabled = Config.getInt("settings.logic.enableSounds", 1) > 0;
setupLogic();
if (FMLCommonHandler.instance().getSide().isClient()) {
this.registerRenderers();
}
NetworkRegistry.INSTANCE.registerGuiHandler(instance, instance);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) {
switch(ID) {
case 1:
return new GuiCounter(player.inventory, CoreLib.getGuiTileEntity(world, X, Y, Z, TileLogicStorage.class));
case 2:
return new GuiTimer(player.inventory, CoreLib.getGuiTileEntity(world, X, Y, Z, TileLogicPointer.class));
default:
return null;
}
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) {
switch(ID) {
case 1:
return new ContainerCounter(player.inventory, CoreLib.getTileEntity(world, X, Y, Z, TileLogicStorage.class));
case 2:
return new ContainerTimer(player.inventory, CoreLib.getTileEntity(world, X, Y, Z, TileLogicPointer.class));
default:
return null;
}
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLib.setHighRenderer(blockLogic, 0, RenderLogicPointer::new);
RenderLib.setHighRenderer(blockLogic, 1, RenderLogicSimple::new);
RenderLib.setHighRenderer(blockLogic, 2, RenderLogicArray::new);
RenderLib.setHighRenderer(blockLogic, 3, RenderLogicStorage::new);
RenderLib.setHighRenderer(blockLogic, 4, RenderLogicAdv::new);
ClientRegistry.bindTileEntitySpecialRenderer(TileLogicAdv.class, new RenderLogicAdv(blockLogic));
ClientRegistry.bindTileEntitySpecialRenderer(TileLogicSimple.class, new RenderLogicSimple(blockLogic));
ClientRegistry.bindTileEntitySpecialRenderer(TileLogicArray.class, new RenderLogicArray(blockLogic));
ClientRegistry.bindTileEntitySpecialRenderer(TileLogicStorage.class, new RenderLogicStorage(blockLogic));
ClientRegistry.bindTileEntitySpecialRenderer(TileLogicPointer.class, new RenderLogicPointer(blockLogic));
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTextureStitch(Pre evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
for(int i = 0; i < 232; ++i) {
logicOne[i] = map.registerIcon("rplogic:logic1/" + i);
}
for(int i = 0; i < 256; ++i) {
logicTwo[i] = map.registerIcon("rplogic:logic2/" + i);
}
for(int i = 0; i < 23; ++i) {
logicSensor[i] = map.registerIcon("rplogic:sensors/" + i);
}
}
}
@SubscribeEvent
public void onTextureStitch(Post evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
torch = map.getAtlasSprite("redstone_torch_off");
torchOn = map.getAtlasSprite("redstone_torch_on");
lever = map.getAtlasSprite("lever");
cobblestone = map.getAtlasSprite("cobblestone");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,195 @@
package com.eloraam.redpower;
import codechicken.nei.ItemStackSet;
import codechicken.nei.SubsetWidget.SubsetTag;
import codechicken.nei.api.API;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.DefaultOverlayHandler;
import com.eloraam.redpower.base.GuiAdvBench;
import com.eloraam.redpower.base.GuiAlloyFurnace;
import com.eloraam.redpower.base.ItemHandsaw;
import com.eloraam.redpower.nei.AlloyFurnaceOverlayHandler;
import com.eloraam.redpower.nei.AlloyFurnaceRecipeHandler;
import com.eloraam.redpower.nei.MicroRecipeHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@Mod(
modid = "RedPowerNEIPlugin",
name = "RedPower NEI Plugin",
version = "1.4.3.1",
dependencies = "after:NotEnoughItems;after:RedPowerBase;after:RedPowerCompat;after:RedPowerControl;after:RedPowerCore;after:RedPowerLighting;after:RedPowerLogic;after:RedPowerMachine;after:RedPowerWiring;after:RedPowerWorld"
)
public class RedPowerNEIPlugin {
@Instance("RedPowerNEIPlugin")
public static RedPowerNEIPlugin instance;
public static boolean wiring;
public static boolean logic;
public static boolean control;
public static boolean lighting;
public static boolean world;
public static boolean machine;
public static boolean base;
public static boolean compat;
static Block micro;
private List<RedPowerNEIPlugin.ItemRange> validMicroTypes = new ArrayList();
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
}
@EventHandler
public void load(FMLInitializationEvent event) {
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
if (FMLCommonHandler.instance().getSide().isServer()) {
FMLLog.severe("[RedPowerNEIPlugin] Server env detected, disabling...", new Object[0]);
} else {
if (Loader.isModLoaded("NotEnoughItems")) {
wiring = Loader.isModLoaded("RedPowerWiring");
logic = Loader.isModLoaded("RedPowerLogic");
control = Loader.isModLoaded("RedPowerControl");
lighting = Loader.isModLoaded("RedPowerLighting");
world = Loader.isModLoaded("RedPowerWorld");
machine = Loader.isModLoaded("RedPowerMachine");
base = Loader.isModLoaded("RedPowerBase");
compat = Loader.isModLoaded("RedPowerCompat");
if (base) {
this.loadCoverSubSets();
this.loadSaws();
API.registerGuiOverlay(GuiAlloyFurnace.class, "alloy");
API.registerGuiOverlay(GuiAdvBench.class, "crafting", 23, 12);
API.registerGuiOverlayHandler(GuiAlloyFurnace.class, new AlloyFurnaceOverlayHandler(), "alloy");
API.registerGuiOverlayHandler(GuiAdvBench.class, new DefaultOverlayHandler(23, 12), "crafting");
API.hideItem(new ItemStack(RedPowerBase.blockMultiblock));
API.registerRecipeHandler(new AlloyFurnaceRecipeHandler());
API.registerUsageHandler(new AlloyFurnaceRecipeHandler());
API.registerRecipeHandler(new MicroRecipeHandler());
API.registerUsageHandler(new MicroRecipeHandler());
}
} else {
FMLCommonHandler.instance().getFMLLogger().warn("[RedPowerNEIPlugin] No NEI detected, disabling...");
}
}
}
private void loadSaws() {
List<ItemHandsaw> saws = new ArrayList();
for(Object item : Item.itemRegistry) {
if (item instanceof ItemHandsaw) {
saws.add((ItemHandsaw)item);
}
}
MicroRecipeHandler.saws = new ItemHandsaw[saws.size()];
for(int i = 0; i < saws.size(); ++i) {
MicroRecipeHandler.saws[i] = (ItemHandsaw)saws.get(i);
}
ItemStackSet set = new ItemStackSet().with(MicroRecipeHandler.saws);
API.addSubset(new SubsetTag("RedPower.Tools.Saws", set));
API.addSubset(new SubsetTag("Items.Tools.Saws", set));
}
private void loadCoverSubSets() {
if (base) {
micro = RedPowerBase.blockMicro;
int startRange = -1;
for(int i = 0; i < 256; ++i) {
ItemStack stack = new ItemStack(micro, 1, i);
String name = GuiContainerManager.itemDisplayNameShort(stack);
if (!name.endsWith("Unnamed") && !name.endsWith("null")) {
if (startRange == -1) {
startRange = i;
}
} else if (startRange != -1) {
this.validMicroTypes.add(new RedPowerNEIPlugin.ItemRange(micro, startRange, i - 1));
startRange = -1;
}
}
this.registerMicroSet("MicroBlocks.Cover", 0);
this.registerMicroSet("MicroBlocks.Panel", 16);
this.registerMicroSet("MicroBlocks.Slab", 17);
this.registerMicroSet("MicroBlocks.Hollow Cover", 24);
this.registerMicroSet("MicroBlocks.Hollow Panel", 25);
this.registerMicroSet("MicroBlocks.Hollow Slab", 26);
this.registerMicroSet("MicroBlocks.Cover Corner", 18);
this.registerMicroSet("MicroBlocks.Panel Corner", 19);
this.registerMicroSet("MicroBlocks.Slab Corner", 20);
this.registerMicroSet("MicroBlocks.Cover Strip", 21);
this.registerMicroSet("MicroBlocks.Panel Strip", 22);
this.registerMicroSet("MicroBlocks.Slab Strip", 23);
this.registerMicroSet("MicroBlocks.Triple Cover", 27);
this.registerMicroSet("MicroBlocks.Cover Slab", 28);
this.registerMicroSet("MicroBlocks.Triple Panel", 29);
this.registerMicroSet("MicroBlocks.Anticover", 30);
this.registerMicroSet("MicroBlocks.Hollow Triple Cover", 31);
this.registerMicroSet("MicroBlocks.Hollow Cover Slab", 32);
this.registerMicroSet("MicroBlocks.Hollow Triple Panel", 33);
this.registerMicroSet("MicroBlocks.Hollow Anticover", 34);
this.registerMicroSet("MicroBlocks.Triple Cover Corner", 35);
this.registerMicroSet("MicroBlocks.Cover Slab Corner", 36);
this.registerMicroSet("MicroBlocks.Triple Panel Corner", 37);
this.registerMicroSet("MicroBlocks.Anticover Corner", 38);
this.registerMicroSet("MicroBlocks.Triple Cover Strip", 39);
this.registerMicroSet("MicroBlocks.Cover Slab Strip", 40);
this.registerMicroSet("MicroBlocks.Triple Panel Strip", 41);
this.registerMicroSet("MicroBlocks.Anticover Strip", 42);
this.registerMicroSet("MicroBlocks.Post", 43);
this.registerMicroSet("MicroBlocks.Pillar", 44);
this.registerMicroSet("MicroBlocks.Column", 45);
if (wiring) {
this.registerMicroSet("Wiring.Jacketed Wire", 64);
this.registerMicroSet("Wiring.Jacketed Cable", 65);
this.registerMicroSet("Bluetricity.Jacketed Bluewire", 66);
}
}
}
private void registerMicroSet(String RPName, int microID) {
ItemStackSet set = new ItemStackSet();
for(RedPowerNEIPlugin.ItemRange type : this.validMicroTypes) {
set.with(
(ItemStack[])IntStream.rangeClosed(type.start, type.end)
.mapToObj(i -> new ItemStack(type.bl, 1, i + microID * 256))
.toArray(x$0 -> new ItemStack[x$0])
);
}
API.addSubset("RedPower." + RPName, set);
}
private class ItemRange {
private final Block bl;
private final int start;
private final int end;
public ItemRange(Block bl, int start, int end) {
this.bl = bl;
this.start = start;
this.end = end;
}
}
}

View File

@ -0,0 +1,270 @@
package com.eloraam.redpower;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CoverLib;
import com.eloraam.redpower.core.CraftLib;
import com.eloraam.redpower.core.RedPowerLib;
import com.eloraam.redpower.core.RenderLib;
import com.eloraam.redpower.core.TileCovered;
import com.eloraam.redpower.wiring.MicroPlacementJacket;
import com.eloraam.redpower.wiring.MicroPlacementWire;
import com.eloraam.redpower.wiring.RenderRedwire;
import com.eloraam.redpower.wiring.TileBluewire;
import com.eloraam.redpower.wiring.TileCable;
import com.eloraam.redpower.wiring.TileInsulatedWire;
import com.eloraam.redpower.wiring.TileRedwire;
import com.eloraam.redpower.wiring.TileWiring;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent.Pre;
import net.minecraftforge.common.MinecraftForge;
@Mod(
modid = "RedPowerWiring",
name = "RedPower Wiring",
version = "2.0pr6",
dependencies = "required-after:RedPowerBase"
)
public class RedPowerWiring {
@Instance("RedPowerWiring")
public static RedPowerWiring instance;
@SideOnly(Side.CLIENT)
public static IIcon redwireTop;
@SideOnly(Side.CLIENT)
public static IIcon redwireFace;
@SideOnly(Side.CLIENT)
public static IIcon bundledTop;
@SideOnly(Side.CLIENT)
public static IIcon bundledFace;
@SideOnly(Side.CLIENT)
public static IIcon powerTop;
@SideOnly(Side.CLIENT)
public static IIcon powerFace;
@SideOnly(Side.CLIENT)
public static IIcon highPowerTop;
@SideOnly(Side.CLIENT)
public static IIcon highPowerFace;
@SideOnly(Side.CLIENT)
public static IIcon jumboSides;
@SideOnly(Side.CLIENT)
public static IIcon jumboTop;
@SideOnly(Side.CLIENT)
public static IIcon jumboCent;
@SideOnly(Side.CLIENT)
public static IIcon jumboCentSide;
@SideOnly(Side.CLIENT)
public static IIcon jumboEnd;
@SideOnly(Side.CLIENT)
public static IIcon jumboCorners;
@SideOnly(Side.CLIENT)
public static IIcon redwireCableOff;
@SideOnly(Side.CLIENT)
public static IIcon redwireCableOn;
@SideOnly(Side.CLIENT)
public static IIcon bluewireCable;
@SideOnly(Side.CLIENT)
public static IIcon bundledCable;
public static IIcon[] insulatedTop = new IIcon[16];
public static IIcon[] insulatedFaceOff = new IIcon[16];
public static IIcon[] insulatedFaceOn = new IIcon[16];
public static IIcon[] bundledColTop = new IIcon[16];
public static IIcon[] bundledColFace = new IIcon[16];
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (FMLCommonHandler.instance().getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(instance);
}
}
@EventHandler
public void load(FMLInitializationEvent event) {
initJacketRecipes();
setupWires();
if (FMLCommonHandler.instance().getSide().isClient()) {
this.registerRenderers();
}
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
private static void initJacketRecipes() {
CoverLib.addMaterialHandler(
material -> {
if (!CoverLib.isTransparent(material)) {
GameRegistry.addRecipe(
new ItemStack(RedPowerBase.blockMicro, 4, 16384 + material),
new Object[]{"SSS", "SRS", "SSS", 'S', new ItemStack(RedPowerBase.blockMicro, 1, material), 'R', RedPowerBase.itemIngotRed}
);
GameRegistry.addRecipe(
new ItemStack(RedPowerBase.blockMicro, 1, 16640 + material),
new Object[]{
"SSS", "SCS", "SSS", 'S', new ItemStack(RedPowerBase.blockMicro, 1, material), 'C', new ItemStack(RedPowerBase.blockMicro, 1, 768)
}
);
GameRegistry.addRecipe(
new ItemStack(RedPowerBase.blockMicro, 4, 16896 + material),
new Object[]{"SSS", "SBS", "SSS", 'S', new ItemStack(RedPowerBase.blockMicro, 1, material), 'B', RedPowerBase.itemIngotBlue}
);
CraftLib.addAlloyResult(CoreLib.copyStack(RedPowerBase.itemIngotRed, 1), new ItemStack(RedPowerBase.blockMicro, 4, 16384 + material));
CraftLib.addAlloyResult(CoreLib.copyStack(RedPowerBase.itemIngotRed, 5), new ItemStack(RedPowerBase.blockMicro, 8, 16640 + material));
CraftLib.addAlloyResult(CoreLib.copyStack(RedPowerBase.itemIngotBlue, 1), new ItemStack(RedPowerBase.blockMicro, 4, 16896 + material));
}
}
);
}
public static void setupWires() {
GameRegistry.registerTileEntity(TileRedwire.class, "Redwire");
GameRegistry.registerTileEntity(TileInsulatedWire.class, "InsRedwire");
GameRegistry.registerTileEntity(TileCable.class, "RedCable");
GameRegistry.registerTileEntity(TileCovered.class, "Covers");
GameRegistry.registerTileEntity(TileBluewire.class, "Bluewire");
MicroPlacementWire wre = new MicroPlacementWire();
RedPowerBase.blockMicro.registerPlacement(1, wre);
RedPowerBase.blockMicro.registerPlacement(2, wre);
RedPowerBase.blockMicro.registerPlacement(3, wre);
RedPowerBase.blockMicro.registerPlacement(5, wre);
MicroPlacementJacket jkt = new MicroPlacementJacket();
RedPowerBase.blockMicro.registerPlacement(64, jkt);
RedPowerBase.blockMicro.registerPlacement(65, jkt);
RedPowerBase.blockMicro.registerPlacement(66, jkt);
RedPowerBase.blockMicro.addTileEntityMapping(1, TileRedwire::new);
RedPowerBase.blockMicro.addTileEntityMapping(2, TileInsulatedWire::new);
RedPowerBase.blockMicro.addTileEntityMapping(3, TileCable::new);
RedPowerBase.blockMicro.addTileEntityMapping(5, TileBluewire::new);
GameRegistry.addRecipe(new ItemStack(RedPowerBase.blockMicro, 12, 256), new Object[]{"R", "R", "R", 'R', RedPowerBase.itemIngotRed});
CraftLib.addAlloyResult(RedPowerBase.itemIngotRed, new ItemStack(RedPowerBase.blockMicro, 4, 256));
CraftLib.addAlloyResult(CoreLib.copyStack(RedPowerBase.itemIngotRed, 5), new ItemStack(RedPowerBase.blockMicro, 8, 768));
GameRegistry.addRecipe(
new ItemStack(RedPowerBase.blockMicro, 12, 1280), new Object[]{"WBW", "WBW", "WBW", 'B', RedPowerBase.itemIngotBlue, 'W', Blocks.wool}
);
CraftLib.addAlloyResult(RedPowerBase.itemIngotBlue, new ItemStack(RedPowerBase.blockMicro, 4, 1280));
GameRegistry.addShapelessRecipe(
new ItemStack(RedPowerBase.blockMicro, 1, 1281), new Object[]{new ItemStack(RedPowerBase.blockMicro, 1, 1280), Blocks.wool}
);
CraftLib.addAlloyResult(RedPowerBase.itemIngotBlue, new ItemStack(RedPowerBase.blockMicro, 4, 1281));
for(int color = 0; color < 16; ++color) {
GameRegistry.addRecipe(
new ItemStack(RedPowerBase.blockMicro, 12, 512 + color),
new Object[]{"WRW", "WRW", "WRW", 'R', RedPowerBase.itemIngotRed, 'W', new ItemStack(Blocks.wool, 1, color)}
);
for(int j = 0; j < 16; ++j) {
if (color != j) {
GameRegistry.addShapelessRecipe(
new ItemStack(RedPowerBase.blockMicro, 1, 512 + color),
new Object[]{new ItemStack(RedPowerBase.blockMicro, 1, 512 + j), new ItemStack(Items.dye, 1, 15 - color)}
);
GameRegistry.addShapelessRecipe(
new ItemStack(RedPowerBase.blockMicro, 1, 769 + color),
new Object[]{new ItemStack(RedPowerBase.blockMicro, 1, 769 + j), new ItemStack(Items.dye, 1, 15 - color)}
);
}
}
CraftLib.addAlloyResult(RedPowerBase.itemIngotRed, new ItemStack(RedPowerBase.blockMicro, 4, 512 + color));
GameRegistry.addRecipe(
new ItemStack(RedPowerBase.blockMicro, 2, 768),
new Object[]{"SWS", "WWW", "SWS", 'W', new ItemStack(RedPowerBase.blockMicro, 1, 512 + color), 'S', Items.string}
);
GameRegistry.addShapelessRecipe(
new ItemStack(RedPowerBase.blockMicro, 1, 769 + color),
new Object[]{new ItemStack(RedPowerBase.blockMicro, 1, 768), new ItemStack(Items.dye, 1, 15 - color), Items.paper}
);
CraftLib.addAlloyResult(CoreLib.copyStack(RedPowerBase.itemIngotRed, 5), new ItemStack(RedPowerBase.blockMicro, 8, 769 + color));
}
for(int i = 0; i < 16; ++i) {
if (i != 11) {
CraftLib.addShapelessOreRecipe(new ItemStack(RedPowerBase.blockMicro, 1, 523), new ItemStack(RedPowerBase.blockMicro, 1, 512 + i), "dyeBlue");
CraftLib.addShapelessOreRecipe(new ItemStack(RedPowerBase.blockMicro, 1, 780), new ItemStack(RedPowerBase.blockMicro, 1, 769 + i), "dyeBlue");
}
}
CraftLib.addShapelessOreRecipe(new ItemStack(RedPowerBase.blockMicro, 1, 780), new ItemStack(RedPowerBase.blockMicro, 1, 768), "dyeBlue", Items.paper);
RedPowerLib.addCompatibleMapping(0, 1);
for(int i = 0; i < 16; ++i) {
RedPowerLib.addCompatibleMapping(0, 2 + i);
RedPowerLib.addCompatibleMapping(1, 2 + i);
RedPowerLib.addCompatibleMapping(65, 2 + i);
for(int j = 0; j < 16; ++j) {
RedPowerLib.addCompatibleMapping(19 + j, 2 + i);
}
RedPowerLib.addCompatibleMapping(18, 2 + i);
RedPowerLib.addCompatibleMapping(18, 19 + i);
}
RedPowerLib.addCompatibleMapping(0, 65);
RedPowerLib.addCompatibleMapping(1, 65);
RedPowerLib.addCompatibleMapping(64, 65);
RedPowerLib.addCompatibleMapping(64, 67);
RedPowerLib.addCompatibleMapping(65, 67);
RedPowerLib.addCompatibleMapping(66, 67);
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLib.setDefaultRenderer(RedPowerBase.blockMicro, 8, RenderRedwire::new);
ClientRegistry.bindTileEntitySpecialRenderer(TileWiring.class, new RenderRedwire(RedPowerBase.blockMicro));
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTextureStitch(Pre evt) {
TextureMap map = evt.map;
if (map.getTextureType() == 0) {
redwireTop = map.registerIcon("rpwiring:redwireTop");
redwireFace = map.registerIcon("rpwiring:redwireFace");
bundledTop = map.registerIcon("rpwiring:bundledTop");
bundledFace = map.registerIcon("rpwiring:bundledFace");
powerTop = map.registerIcon("rpwiring:powerTop");
powerFace = map.registerIcon("rpwiring:powerFace");
highPowerTop = map.registerIcon("rpwiring:highPowerTop");
highPowerFace = map.registerIcon("rpwiring:highPowerFace");
jumboSides = map.registerIcon("rpwiring:jumboSides");
jumboTop = map.registerIcon("rpwiring:jumboTop");
jumboCent = map.registerIcon("rpwiring:jumboCent");
jumboCentSide = map.registerIcon("rpwiring:jumboCentSide");
jumboEnd = map.registerIcon("rpwiring:jumboEnd");
jumboCorners = map.registerIcon("rpwiring:jumboCorners");
redwireCableOff = map.registerIcon("rpwiring:redwireCableOff");
redwireCableOn = map.registerIcon("rpwiring:redwireCableOn");
bluewireCable = map.registerIcon("rpwiring:bluewireCable");
bundledCable = map.registerIcon("rpwiring:bundledCable");
for(int col = 0; col < 16; ++col) {
insulatedTop[col] = map.registerIcon("rpwiring:insulatedTop/" + col);
insulatedFaceOff[col] = map.registerIcon("rpwiring:insulatedFaceOff/" + col);
insulatedFaceOn[col] = map.registerIcon("rpwiring:insulatedFaceOn/" + col);
bundledColTop[col] = map.registerIcon("rpwiring:bundledColTop/" + col);
bundledColFace[col] = map.registerIcon("rpwiring:bundledColFace/" + col);
}
}
}
}

View File

@ -0,0 +1,495 @@
package com.eloraam.redpower;
import com.eloraam.redpower.base.ItemHandsaw;
import com.eloraam.redpower.core.Config;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CoverLib;
import com.eloraam.redpower.core.CraftLib;
import com.eloraam.redpower.core.ItemPartialCraft;
import com.eloraam.redpower.core.ItemTextured;
import com.eloraam.redpower.world.BlockCustomCrops;
import com.eloraam.redpower.world.BlockCustomFlower;
import com.eloraam.redpower.world.BlockCustomLeaves;
import com.eloraam.redpower.world.BlockCustomLog;
import com.eloraam.redpower.world.BlockCustomOre;
import com.eloraam.redpower.world.BlockCustomStone;
import com.eloraam.redpower.world.BlockStorage;
import com.eloraam.redpower.world.ContainerSeedBag;
import com.eloraam.redpower.world.EnchantmentDisjunction;
import com.eloraam.redpower.world.EnchantmentVorpal;
import com.eloraam.redpower.world.GuiSeedBag;
import com.eloraam.redpower.world.ItemAthame;
import com.eloraam.redpower.world.ItemCustomAxe;
import com.eloraam.redpower.world.ItemCustomFlower;
import com.eloraam.redpower.world.ItemCustomHoe;
import com.eloraam.redpower.world.ItemCustomOre;
import com.eloraam.redpower.world.ItemCustomPickaxe;
import com.eloraam.redpower.world.ItemCustomSeeds;
import com.eloraam.redpower.world.ItemCustomShovel;
import com.eloraam.redpower.world.ItemCustomStone;
import com.eloraam.redpower.world.ItemCustomSword;
import com.eloraam.redpower.world.ItemPaintBrush;
import com.eloraam.redpower.world.ItemPaintCan;
import com.eloraam.redpower.world.ItemSeedBag;
import com.eloraam.redpower.world.ItemSickle;
import com.eloraam.redpower.world.ItemStorage;
import com.eloraam.redpower.world.ItemWoolCard;
import com.eloraam.redpower.world.WorldEvents;
import com.eloraam.redpower.world.WorldGenHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.OreDictionary;
@Mod(
modid = "RedPowerWorld",
name = "RedPower World",
version = "2.0pr6",
dependencies = "required-after:RedPowerBase"
)
public class RedPowerWorld implements IGuiHandler {
@Instance("RedPowerWorld")
public static RedPowerWorld instance;
public static BlockCustomFlower blockPlants;
public static BlockCustomOre blockOres;
public static BlockCustomLeaves blockLeaves;
public static BlockCustomLog blockLogs;
public static BlockCustomStone blockStone;
public static BlockCustomCrops blockCrops;
public static BlockStorage blockStorage;
public static ItemStack itemOreRuby;
public static ItemStack itemOreGreenSapphire;
public static ItemStack itemOreSapphire;
public static ItemStack itemMarble;
public static ItemStack itemBasalt;
public static ItemStack itemBasaltCobble;
public static ToolMaterial toolMaterialRuby;
public static ToolMaterial toolMaterialGreenSapphire;
public static ToolMaterial toolMaterialSapphire;
public static ItemSickle itemSickleWood;
public static ItemSickle itemSickleStone;
public static ItemSickle itemSickleIron;
public static ItemSickle itemSickleDiamond;
public static ItemSickle itemSickleGold;
public static ItemSickle itemSickleRuby;
public static ItemSickle itemSickleGreenSapphire;
public static ItemSickle itemSickleSapphire;
public static ItemCustomPickaxe itemPickaxeRuby;
public static ItemCustomPickaxe itemPickaxeGreenSapphire;
public static ItemCustomPickaxe itemPickaxeSapphire;
public static ItemCustomShovel itemShovelRuby;
public static ItemCustomShovel setUnlocalizedName;
public static ItemCustomShovel itemShovelSapphire;
public static ItemCustomShovel itemShovelGreenSapphire;
public static ItemCustomAxe itemAxeRuby;
public static ItemCustomAxe itemAxeGreenSapphire;
public static ItemCustomAxe itemAxeSapphire;
public static ItemCustomSword itemSwordRuby;
public static ItemCustomSword itemSwordGreenSapphire;
public static ItemCustomSword itemSwordSapphire;
public static ItemAthame itemAthame;
public static ItemCustomHoe itemHoeRuby;
public static ItemCustomHoe itemHoeGreenSapphire;
public static ItemCustomHoe itemHoeSapphire;
public static ItemCustomSeeds itemSeeds;
public static Item itemHandsawRuby;
public static Item itemHandsawGreenSapphire;
public static Item itemHandsawSapphire;
public static Item itemBrushDry;
public static Item itemPaintCanEmpty;
public static Item[] itemBrushPaint = new Item[16];
public static ItemPartialCraft[] itemPaintCanPaint = new ItemPartialCraft[16];
public static Item itemWoolCard;
public static Item itemSeedBag;
public static Enchantment enchantDisjunction;
public static Enchantment enchantVorpal;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new WorldEvents());
}
@EventHandler
public void load(FMLInitializationEvent event) {
GameRegistry.registerWorldGenerator(new WorldGenHandler(), 1);
this.setupOres();
this.setupPlants();
this.setupTools();
this.setupMisc();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, instance);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
public void setupPlants() {
blockPlants = new BlockCustomFlower("rpworld:indigoFlower", "rpworld:rubberSapling");
blockPlants.setBlockName("plant");
GameRegistry.registerBlock(blockPlants, ItemCustomFlower.class, "plants");
GameRegistry.addShapelessRecipe(new ItemStack(RedPowerBase.itemDyeIndigo, 2, 0), new Object[]{blockPlants});
itemSeeds = new ItemCustomSeeds();
MinecraftForge.addGrassSeed(new ItemStack(itemSeeds, 1, 0), 5);
blockCrops = new BlockCustomCrops();
GameRegistry.registerBlock(blockCrops, "flax");
GameRegistry.registerItem(itemSeeds, "flaxseeds");
blockLeaves = new BlockCustomLeaves("rpworld:rubberLeaves_opaque", "rpworld:rubberLeaves_transparent");
blockLeaves.setBlockName("rpleaves");
GameRegistry.registerBlock(blockLeaves, "leaves");
blockLogs = new BlockCustomLog("rpworld:rubberLogSide", "rpworld:rubberLogTop");
blockLogs.setBlockName("rplog");
GameRegistry.registerBlock(blockLogs, "logs");
blockLogs.setHarvestLevel("axe", 0, 0);
OreDictionary.registerOre("woodRubber", new ItemStack(blockLogs));
GameRegistry.addRecipe(new ItemStack(Items.stick, 8), new Object[]{"W", 'W', blockLogs});
GameRegistry.addSmelting(new ItemStack(blockLogs, 1, 0), new ItemStack(Items.coal, 1, 1), 0.15F);
CoverLib.addMaterial(53, 0, blockLogs, 0, "rplog");
}
public void setupOres() {
blockStone = new BlockCustomStone();
blockStone.setBlockName("rpstone");
GameRegistry.registerBlock(blockStone, ItemCustomStone.class, "stone");
itemMarble = new ItemStack(blockStone, 0);
itemBasalt = new ItemStack(blockStone, 1);
itemBasaltCobble = new ItemStack(blockStone, 3);
blockStone.setHarvestLevel("pickaxe", 0);
blockStone.setBlockTexture(0, "rpworld:marble");
blockStone.setBlockTexture(1, "rpworld:basalt");
blockStone.setBlockTexture(2, "rpworld:marbleBrick");
blockStone.setBlockTexture(3, "rpworld:basaltCobble");
blockStone.setBlockTexture(4, "rpworld:basaltBrick");
blockStone.setBlockTexture(5, "rpworld:chiseledBasaltBrick");
blockStone.setBlockTexture(6, "rpworld:basaltPaver");
CoverLib.addMaterial(48, 1, blockStone, 0, "marble");
CoverLib.addMaterial(49, 1, blockStone, 1, "basalt");
CoverLib.addMaterial(50, 1, blockStone, 2, "marbleBrick");
CoverLib.addMaterial(51, 1, blockStone, 3, "basaltCobble");
CoverLib.addMaterial(52, 1, blockStone, 4, "basaltBrick");
CoverLib.addMaterial(57, 1, blockStone, 5, "basaltCircle");
CoverLib.addMaterial(58, 1, blockStone, 6, "basaltPaver");
blockOres = new BlockCustomOre();
GameRegistry.registerBlock(blockOres, ItemCustomOre.class, "ores");
itemOreRuby = new ItemStack(blockOres, 1, 0);
itemOreGreenSapphire = new ItemStack(blockOres, 1, 1);
itemOreSapphire = new ItemStack(blockOres, 1, 2);
blockOres.setHarvestLevel("pickaxe", 2, 0);
blockOres.setHarvestLevel("pickaxe", 2, 1);
blockOres.setHarvestLevel("pickaxe", 2, 2);
blockOres.setHarvestLevel("pickaxe", 1, 3);
blockOres.setHarvestLevel("pickaxe", 0, 4);
blockOres.setHarvestLevel("pickaxe", 0, 5);
blockOres.setHarvestLevel("pickaxe", 2, 6);
blockOres.setHarvestLevel("pickaxe", 2, 7);
GameRegistry.addSmelting(new ItemStack(blockOres, 1, 3), RedPowerBase.itemIngotSilver, 1.0F);
GameRegistry.addSmelting(new ItemStack(blockOres, 1, 4), RedPowerBase.itemIngotTin, 0.7F);
GameRegistry.addSmelting(new ItemStack(blockOres, 1, 5), RedPowerBase.itemIngotCopper, 0.7F);
GameRegistry.addSmelting(new ItemStack(blockOres, 1, 6), RedPowerBase.itemIngotTungsten, 1.2F);
GameRegistry.addSmelting(new ItemStack(RedPowerBase.itemResource, 2, 9), RedPowerBase.itemIngotSilver, 1.0F);
GameRegistry.addSmelting(new ItemStack(RedPowerBase.itemResource, 2, 8), RedPowerBase.itemIngotTungsten, 1.2F);
OreDictionary.registerOre("oreRuby", new ItemStack(blockOres, 1, 0));
OreDictionary.registerOre("oreGreenSapphire", new ItemStack(blockOres, 1, 1));
OreDictionary.registerOre("oreSapphire", new ItemStack(blockOres, 1, 2));
OreDictionary.registerOre("oreSilver", new ItemStack(blockOres, 1, 3));
OreDictionary.registerOre("oreTin", new ItemStack(blockOres, 1, 4));
OreDictionary.registerOre("oreCopper", new ItemStack(blockOres, 1, 5));
OreDictionary.registerOre("oreTungsten", new ItemStack(blockOres, 1, 6));
OreDictionary.registerOre("oreNikolite", new ItemStack(blockOres, 1, 7));
GameRegistry.addRecipe(new ItemStack(blockStone, 4, 2), new Object[]{"SS", "SS", 'S', new ItemStack(blockStone, 1, 0)});
GameRegistry.addSmelting(new ItemStack(blockStone, 1, 3), new ItemStack(blockStone, 1, 1), 0.2F);
GameRegistry.addRecipe(new ItemStack(blockStone, 4, 4), new Object[]{"SS", "SS", 'S', new ItemStack(blockStone, 1, 1)});
GameRegistry.addRecipe(new ItemStack(blockStone, 4, 5), new Object[]{"SS", "SS", 'S', new ItemStack(blockStone, 1, 4)});
GameRegistry.addRecipe(new ItemStack(blockStone, 1, 6), new Object[]{"S", 'S', new ItemStack(blockStone, 1, 1)});
blockStorage = new BlockStorage();
GameRegistry.registerBlock(blockStorage, ItemStorage.class, "orestorage");
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 0), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemRuby});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 1), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemGreenSapphire});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 2), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemSapphire});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 3), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemIngotSilver});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 4), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemIngotTin});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 5), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemIngotCopper});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 6), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemIngotTungsten});
GameRegistry.addRecipe(new ItemStack(blockStorage, 1, 7), new Object[]{"GGG", "GGG", "GGG", 'G', RedPowerBase.itemNikolite});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemRuby, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 0)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemGreenSapphire, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 1)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemSapphire, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 2)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemIngotSilver, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 3)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemIngotTin, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 4)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemIngotCopper, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 5)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemIngotTungsten, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 6)});
GameRegistry.addRecipe(CoreLib.copyStack(RedPowerBase.itemNikolite, 9), new Object[]{"G", 'G', new ItemStack(blockStorage, 1, 7)});
blockStorage.setHarvestLevel("pickaxe", 2, 0);
blockStorage.setHarvestLevel("pickaxe", 2, 1);
blockStorage.setHarvestLevel("pickaxe", 2, 2);
blockStorage.setHarvestLevel("pickaxe", 2, 3);
blockStorage.setHarvestLevel("pickaxe", 2, 4);
blockStorage.setHarvestLevel("pickaxe", 2, 5);
blockStorage.setHarvestLevel("pickaxe", 3, 6);
blockStorage.setHarvestLevel("pickaxe", 2, 7);
CoverLib.addMaterial(54, 2, blockStorage, 0, "rubyBlock");
CoverLib.addMaterial(55, 2, blockStorage, 1, "greenSapphireBlock");
CoverLib.addMaterial(56, 2, blockStorage, 2, "sapphireBlock");
CoverLib.addMaterial(66, 2, blockStorage, 3, "silverBlock");
CoverLib.addMaterial(67, 2, blockStorage, 4, "tinBlock");
CoverLib.addMaterial(68, 2, blockStorage, 5, "copperBlock");
CoverLib.addMaterial(69, 2, blockStorage, 6, "tungstenBlock");
}
public void setupTools() {
toolMaterialRuby = EnumHelper.addToolMaterial("RUBY", 2, 500, 8.0F, 3.0F, 12);
toolMaterialGreenSapphire = EnumHelper.addToolMaterial("GREENSAPPHIRE", 2, 500, 8.0F, 3.0F, 12);
toolMaterialSapphire = EnumHelper.addToolMaterial("SAPPHIRE", 2, 500, 8.0F, 3.0F, 12);
itemPickaxeRuby = new ItemCustomPickaxe(toolMaterialRuby);
itemPickaxeRuby.setUnlocalizedName("pickaxeRuby");
itemPickaxeRuby.setTextureName("rpworld:pickaxeRuby");
GameRegistry.registerItem(itemPickaxeRuby, "rubyPickaxe");
itemPickaxeGreenSapphire = new ItemCustomPickaxe(toolMaterialGreenSapphire);
itemPickaxeGreenSapphire.setUnlocalizedName("pickaxeGreenSapphire");
itemPickaxeGreenSapphire.setTextureName("rpworld:pickaxeGreenSapphire");
GameRegistry.registerItem(itemPickaxeGreenSapphire, "greenSapphirePickaxe");
itemPickaxeSapphire = new ItemCustomPickaxe(toolMaterialSapphire);
itemPickaxeSapphire.setUnlocalizedName("pickaxeSapphire");
itemPickaxeSapphire.setTextureName("rpworld:pickaxeSapphire");
GameRegistry.registerItem(itemPickaxeSapphire, "sapphirePickaxe");
itemPickaxeRuby.setHarvestLevel("pickaxe", 2);
itemPickaxeGreenSapphire.setHarvestLevel("pickaxe", 2);
itemPickaxeSapphire.setHarvestLevel("pickaxe", 2);
GameRegistry.addRecipe(new ItemStack(itemPickaxeRuby, 1), new Object[]{"GGG", " W ", " W ", 'G', RedPowerBase.itemRuby, 'W', Items.stick});
GameRegistry.addRecipe(
new ItemStack(itemPickaxeGreenSapphire, 1), new Object[]{"GGG", " W ", " W ", 'G', RedPowerBase.itemGreenSapphire, 'W', Items.stick}
);
GameRegistry.addRecipe(new ItemStack(itemPickaxeSapphire, 1), new Object[]{"GGG", " W ", " W ", 'G', RedPowerBase.itemSapphire, 'W', Items.stick});
itemShovelRuby = new ItemCustomShovel(toolMaterialRuby);
itemShovelRuby.setUnlocalizedName("shovelRuby");
itemShovelRuby.setTextureName("rpworld:shovelRuby");
GameRegistry.registerItem(itemShovelRuby, "rubyShovel");
itemShovelGreenSapphire = new ItemCustomShovel(toolMaterialGreenSapphire);
itemShovelGreenSapphire.setUnlocalizedName("shovelGreenSapphire");
itemShovelGreenSapphire.setTextureName("rpworld:shovelGreenSapphire");
GameRegistry.registerItem(itemShovelGreenSapphire, "greenSapphireShovel");
itemShovelSapphire = new ItemCustomShovel(toolMaterialSapphire);
itemShovelSapphire.setUnlocalizedName("shovelSapphire");
itemShovelSapphire.setTextureName("rpworld:shovelSapphire");
GameRegistry.registerItem(itemShovelSapphire, "sapphireShovel");
itemShovelRuby.setHarvestLevel("shovel", 2);
itemShovelGreenSapphire.setHarvestLevel("shovel", 2);
itemShovelSapphire.setHarvestLevel("shovel", 2);
GameRegistry.addRecipe(new ItemStack(itemShovelRuby, 1), new Object[]{"G", "W", "W", 'G', RedPowerBase.itemRuby, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemShovelGreenSapphire, 1), new Object[]{"G", "W", "W", 'G', RedPowerBase.itemGreenSapphire, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemShovelSapphire, 1), new Object[]{"G", "W", "W", 'G', RedPowerBase.itemSapphire, 'W', Items.stick});
itemAxeRuby = new ItemCustomAxe(toolMaterialRuby);
itemAxeRuby.setUnlocalizedName("axeRuby");
itemAxeRuby.setTextureName("rpworld:axeRuby");
GameRegistry.registerItem(itemAxeRuby, "rubyAxe");
itemAxeGreenSapphire = new ItemCustomAxe(toolMaterialGreenSapphire);
itemAxeGreenSapphire.setUnlocalizedName("axeGreenSapphire");
itemAxeGreenSapphire.setTextureName("rpworld:axeGreenSapphire");
GameRegistry.registerItem(itemAxeGreenSapphire, "greenSapphireAxe");
itemAxeSapphire = new ItemCustomAxe(toolMaterialSapphire);
itemAxeSapphire.setUnlocalizedName("axeSapphire");
itemAxeSapphire.setTextureName("rpworld:axeSapphire");
GameRegistry.registerItem(itemAxeSapphire, "sapphireAxe");
itemAxeRuby.setHarvestLevel("axe", 2);
itemAxeGreenSapphire.setHarvestLevel("axe", 2);
itemAxeSapphire.setHarvestLevel("axe", 2);
GameRegistry.addRecipe(new ItemStack(itemAxeRuby, 1), new Object[]{"GG", "GW", " W", 'G', RedPowerBase.itemRuby, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemAxeGreenSapphire, 1), new Object[]{"GG", "GW", " W", 'G', RedPowerBase.itemGreenSapphire, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemAxeSapphire, 1), new Object[]{"GG", "GW", " W", 'G', RedPowerBase.itemSapphire, 'W', Items.stick});
itemSwordRuby = new ItemCustomSword(toolMaterialRuby);
itemSwordRuby.setUnlocalizedName("swordRuby");
itemSwordRuby.setTextureName("rpworld:swordRuby");
GameRegistry.registerItem(itemSwordRuby, "rubySword");
itemSwordGreenSapphire = new ItemCustomSword(toolMaterialGreenSapphire);
itemSwordGreenSapphire.setUnlocalizedName("swordGreenSapphire");
itemSwordGreenSapphire.setTextureName("rpworld:swordGreenSapphire");
GameRegistry.registerItem(itemSwordGreenSapphire, "greenSapphireSword");
itemSwordSapphire = new ItemCustomSword(toolMaterialSapphire);
itemSwordSapphire.setUnlocalizedName("swordSapphire");
itemSwordSapphire.setTextureName("rpworld:swordSapphire");
GameRegistry.registerItem(itemSwordSapphire, "sapphireSword");
itemAthame = new ItemAthame();
itemAthame.setUnlocalizedName("athame");
GameRegistry.registerItem(itemAthame, "athame");
CraftLib.addOreRecipe(new ItemStack(itemAthame, 1), "S", "W", 'S', "ingotSilver", 'W', Items.stick);
GameRegistry.addRecipe(new ItemStack(itemSwordRuby, 1), new Object[]{"G", "G", "W", 'G', RedPowerBase.itemRuby, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemSwordGreenSapphire, 1), new Object[]{"G", "G", "W", 'G', RedPowerBase.itemGreenSapphire, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemSwordSapphire, 1), new Object[]{"G", "G", "W", 'G', RedPowerBase.itemSapphire, 'W', Items.stick});
itemHoeRuby = new ItemCustomHoe(toolMaterialRuby);
itemHoeRuby.setUnlocalizedName("hoeRuby");
itemHoeRuby.setTextureName("rpworld:hoeRuby");
itemHoeRuby.setMaxDamage(500);
GameRegistry.registerItem(itemHoeRuby, "rubyHoe");
itemHoeGreenSapphire = new ItemCustomHoe(toolMaterialGreenSapphire);
itemHoeGreenSapphire.setUnlocalizedName("hoeGreenSapphire");
itemHoeGreenSapphire.setTextureName("rpworld:hoeGreenSapphire");
itemHoeGreenSapphire.setMaxDamage(500);
GameRegistry.registerItem(itemHoeGreenSapphire, "greenSapphireHoe");
itemHoeSapphire = new ItemCustomHoe(toolMaterialSapphire);
itemHoeSapphire.setUnlocalizedName("hoeSapphire");
itemHoeSapphire.setTextureName("rpworld:hoeSapphire");
itemHoeSapphire.setMaxDamage(500);
GameRegistry.registerItem(itemHoeSapphire, "sapphireHoe");
itemHoeRuby.setHarvestLevel("hoe", 2);
itemHoeGreenSapphire.setHarvestLevel("hoe", 2);
itemHoeSapphire.setHarvestLevel("hoe", 2);
GameRegistry.addRecipe(new ItemStack(itemHoeRuby, 1), new Object[]{"GG", " W", " W", 'G', RedPowerBase.itemRuby, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemHoeGreenSapphire, 1), new Object[]{"GG", " W", " W", 'G', RedPowerBase.itemGreenSapphire, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemHoeSapphire, 1), new Object[]{"GG", " W", " W", 'G', RedPowerBase.itemSapphire, 'W', Items.stick});
itemSickleWood = new ItemSickle(ToolMaterial.WOOD);
itemSickleWood.setUnlocalizedName("sickleWood");
itemSickleWood.setTextureName("rpworld:sickleWood");
GameRegistry.registerItem(itemSickleWood, "woodenSickle");
itemSickleStone = new ItemSickle(ToolMaterial.STONE);
itemSickleStone.setUnlocalizedName("sickleStone");
itemSickleStone.setTextureName("rpworld:sickleStone");
GameRegistry.registerItem(itemSickleStone, "stoneSickle");
itemSickleIron = new ItemSickle(ToolMaterial.IRON);
itemSickleIron.setUnlocalizedName("sickleIron");
itemSickleIron.setTextureName("rpworld:sickleIron");
GameRegistry.registerItem(itemSickleIron, "ironSickle");
itemSickleDiamond = new ItemSickle(ToolMaterial.EMERALD);
itemSickleDiamond.setUnlocalizedName("sickleDiamond");
itemSickleDiamond.setTextureName("rpworld:sickleDiamond");
GameRegistry.registerItem(itemSickleDiamond, "diamondSickle");
itemSickleGold = new ItemSickle(ToolMaterial.GOLD);
itemSickleGold.setUnlocalizedName("sickleGold");
itemSickleGold.setTextureName("rpworld:sickleGold");
GameRegistry.registerItem(itemSickleGold, "goldSickle");
itemSickleRuby = new ItemSickle(toolMaterialRuby);
itemSickleRuby.setUnlocalizedName("sickleRuby");
itemSickleRuby.setTextureName("rpworld:sickleRuby");
GameRegistry.registerItem(itemSickleRuby, "rubySickle");
itemSickleGreenSapphire = new ItemSickle(toolMaterialGreenSapphire);
itemSickleGreenSapphire.setUnlocalizedName("sickleGreenSapphire");
itemSickleGreenSapphire.setTextureName("rpworld:sickleGreenSapphire");
GameRegistry.registerItem(itemSickleGreenSapphire, "greenSapphireSickle");
itemSickleSapphire = new ItemSickle(toolMaterialSapphire);
itemSickleSapphire.setUnlocalizedName("sickleSapphire");
itemSickleSapphire.setTextureName("rpworld:sickleSapphire");
GameRegistry.registerItem(itemSickleSapphire, "sapphireSickle");
CraftLib.addOreRecipe(new ItemStack(itemSickleWood, 1), " I ", " I", "WI ", 'I', "plankWood", 'W', Items.stick);
GameRegistry.addRecipe(new ItemStack(itemSickleStone, 1), new Object[]{" I ", " I", "WI ", 'I', Blocks.cobblestone, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemSickleIron, 1), new Object[]{" I ", " I", "WI ", 'I', Items.iron_ingot, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemSickleDiamond, 1), new Object[]{" I ", " I", "WI ", 'I', Items.diamond, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemSickleGold, 1), new Object[]{" I ", " I", "WI ", 'I', Items.gold_ingot, 'W', Items.stick});
GameRegistry.addRecipe(new ItemStack(itemSickleRuby, 1), new Object[]{" I ", " I", "WI ", 'I', RedPowerBase.itemRuby, 'W', Items.stick});
GameRegistry.addRecipe(
new ItemStack(itemSickleGreenSapphire, 1), new Object[]{" I ", " I", "WI ", 'I', RedPowerBase.itemGreenSapphire, 'W', Items.stick}
);
GameRegistry.addRecipe(new ItemStack(itemSickleSapphire, 1), new Object[]{" I ", " I", "WI ", 'I', RedPowerBase.itemSapphire, 'W', Items.stick});
itemHandsawRuby = new ItemHandsaw(1);
itemHandsawGreenSapphire = new ItemHandsaw(1);
itemHandsawSapphire = new ItemHandsaw(1);
itemHandsawRuby.setUnlocalizedName("handsawRuby").setTextureName("rpworld:handsawRuby");
itemHandsawGreenSapphire.setUnlocalizedName("handsawGreenSapphire").setTextureName("rpworld:handsawGreenSapphire");
itemHandsawSapphire.setUnlocalizedName("handsawSapphire").setTextureName("rpworld:handsawSapphire");
itemHandsawRuby.setMaxDamage(640);
itemHandsawGreenSapphire.setMaxDamage(640);
itemHandsawSapphire.setMaxDamage(640);
GameRegistry.registerItem(itemHandsawRuby, "rubyHandshaw");
GameRegistry.registerItem(itemHandsawGreenSapphire, "greenSapphireHandshaw");
GameRegistry.registerItem(itemHandsawSapphire, "sapphireHandshaw");
GameRegistry.addRecipe(
new ItemStack(itemHandsawRuby, 1), new Object[]{"WWW", " II", " GG", 'I', Items.iron_ingot, 'G', RedPowerBase.itemRuby, 'W', Items.stick}
);
GameRegistry.addRecipe(
new ItemStack(itemHandsawGreenSapphire, 1),
new Object[]{"WWW", " II", " GG", 'I', Items.iron_ingot, 'G', RedPowerBase.itemGreenSapphire, 'W', Items.stick}
);
GameRegistry.addRecipe(
new ItemStack(itemHandsawSapphire, 1), new Object[]{"WWW", " II", " GG", 'I', Items.iron_ingot, 'G', RedPowerBase.itemSapphire, 'W', Items.stick}
);
itemWoolCard = new ItemWoolCard();
GameRegistry.registerItem(itemWoolCard, "woolCard");
CraftLib.addOreRecipe(new ItemStack(itemWoolCard, 1), "W", "P", "S", 'W', RedPowerBase.itemFineIron, 'P', "plankWood", 'S', Items.stick);
GameRegistry.addShapelessRecipe(new ItemStack(Items.string, 4), new Object[]{new ItemStack(itemWoolCard, 1, 32767), new ItemStack(Blocks.wool, 1, 32767)});
itemBrushDry = new ItemTextured("rpworld:brushDry");
itemBrushDry.setCreativeTab(CreativeTabs.tabTools);
itemBrushDry.setUnlocalizedName("paintbrush.dry");
GameRegistry.registerItem(itemBrushDry, "dryBush");
GameRegistry.addRecipe(new ItemStack(itemBrushDry), new Object[]{"W ", " S", 'S', Items.stick, 'W', Blocks.wool});
itemPaintCanEmpty = new ItemTextured("rpworld:paintCanEmpty");
itemPaintCanEmpty.setCreativeTab(CreativeTabs.tabTools);
itemPaintCanEmpty.setUnlocalizedName("paintcan.empty");
GameRegistry.registerItem(itemPaintCanEmpty, "emptyPainCan");
GameRegistry.addRecipe(new ItemStack(itemPaintCanEmpty, 3), new Object[]{"T T", "T T", "TTT", 'T', RedPowerBase.itemTinplate});
for(int color = 0; color < 16; ++color) {
itemPaintCanPaint[color] = new ItemPaintCan(color);
itemPaintCanPaint[color].setUnlocalizedName("paintcan." + CoreLib.rawColorNames[color]);
itemPaintCanPaint[color].setEmptyItem(new ItemStack(itemPaintCanEmpty));
GameRegistry.registerItem(itemPaintCanPaint[color], CoreLib.rawColorNames[color] + "PainCan");
GameRegistry.addShapelessRecipe(
new ItemStack(itemPaintCanPaint[color]),
new Object[]{itemPaintCanEmpty, new ItemStack(Items.dye, 1, 15 - color), new ItemStack(itemSeeds, 1, 0), new ItemStack(itemSeeds, 1, 0)}
);
}
for(int color = 0; color < 16; ++color) {
itemBrushPaint[color] = new ItemPaintBrush(color);
itemBrushPaint[color].setUnlocalizedName("paintbrush." + CoreLib.rawColorNames[color]);
GameRegistry.registerItem(itemBrushPaint[color], CoreLib.rawColorNames[color] + "PainBrush");
GameRegistry.addShapelessRecipe(new ItemStack(itemBrushPaint[color]), new Object[]{new ItemStack(itemPaintCanPaint[color], 1, 32767), itemBrushDry});
}
CraftLib.addShapelessOreRecipe(
new ItemStack(itemPaintCanPaint[11]), itemPaintCanEmpty, "dyeBlue", new ItemStack(itemSeeds, 1, 0), new ItemStack(itemSeeds, 1, 0)
);
itemSeedBag = new ItemSeedBag();
GameRegistry.registerItem(itemSeedBag, "seedBag");
GameRegistry.addRecipe(new ItemStack(itemSeedBag, 1, 0), new Object[]{" S ", "C C", "CCC", 'S', Items.string, 'C', RedPowerBase.itemCanvas});
}
public void setupMisc() {
if (Config.getInt("settings.world.tweaks.spreadmoss", 1) > 0) {
}
if (Config.getInt("settings.world.tweaks.craftcircle", 1) > 0) {
GameRegistry.addRecipe(new ItemStack(Blocks.stonebrick, 4, 3), new Object[]{"BB", "BB", 'B', new ItemStack(Blocks.stonebrick, 1, 0)});
}
if (Config.getInt("settings.world.tweaks.unbricks", 1) > 0) {
GameRegistry.addShapelessRecipe(new ItemStack(Items.brick, 4, 0), new Object[]{new ItemStack(Blocks.brick_block, 1, 0)});
}
enchantDisjunction = new EnchantmentDisjunction(Config.getInt("enchant.disjunction.id", 79), 10);
enchantVorpal = new EnchantmentVorpal(Config.getInt("enchant.vorpal.id", 80), 10);
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID) {
case 1:
return new GuiSeedBag(player.inventory, new InventoryBasic("", true, 9));
default:
return null;
}
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID) {
case 1:
ItemStack heldItem = player.getHeldItem();
return new ContainerSeedBag(player.inventory, ItemSeedBag.getBagInventory(heldItem, player), heldItem);
default:
return null;
}
}
}

View File

@ -0,0 +1,39 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.BlockExtended;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CreativeExtraTabs;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
public class BlockAppliance extends BlockExtended {
public BlockAppliance() {
super(Material.rock);
this.setHardness(2.0F);
this.setCreativeTab(CreativeExtraTabs.tabMachine);
}
public int getLightValue(IBlockAccess iba, int i, int j, int k) {
TileAppliance taf = CoreLib.getTileEntity(iba, i, j, k, TileAppliance.class);
return taf == null ? super.getLightValue(iba, i, j, k) : taf.getLightValue();
}
@Override
public boolean isOpaqueCube() {
return true;
}
public boolean isNormalCube() {
return true;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public int damageDropped(int meta) {
return meta;
}
}

View File

@ -0,0 +1,34 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.BlockCoverable;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CreativeExtraTabs;
import com.eloraam.redpower.core.IMicroPlacement;
import com.eloraam.redpower.core.RedPowerLib;
import net.minecraft.item.Item;
import net.minecraft.world.IBlockAccess;
public class BlockMicro extends BlockCoverable {
public BlockMicro() {
super(CoreLib.materialRedpower);
this.setHardness(0.1F);
this.setCreativeTab(CreativeExtraTabs.tabWires);
}
public boolean canProvidePower() {
return !RedPowerLib.isSearching();
}
public boolean canConnectRedstone(IBlockAccess iba, int x, int y, int z, int side) {
if (RedPowerLib.isSearching()) {
return false;
} else {
int md = iba.getBlockMetadata(x, y, z);
return md == 1 || md == 2;
}
}
public void registerPlacement(int md, IMicroPlacement imp) {
((ItemMicro)Item.getItemFromBlock(this)).registerPlacement(md, imp);
}
}

View File

@ -0,0 +1,10 @@
package com.eloraam.redpower.base;
import net.minecraft.block.BlockCompressed;
import net.minecraft.block.material.MapColor;
public class BlockNikolite extends BlockCompressed {
public BlockNikolite() {
super(MapColor.cyanColor);
}
}

View File

@ -0,0 +1,442 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.IHandleGuiEvent;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class ContainerAdvBench extends Container implements IHandleGuiEvent {
SlotCraftRefill slotCraft;
private TileAdvBench tileAdvBench;
public InventorySubCraft craftMatrix;
public IInventory craftResult;
public InventoryCrafting fakeInv;
public int satisfyMask;
public ContainerAdvBench(InventoryPlayer inv, TileAdvBench td) {
this.tileAdvBench = td;
this.craftMatrix = new InventorySubCraft(this, td);
this.craftResult = new InventoryCraftResult();
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 3; ++j) {
this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 48 + j * 18, 18 + i * 18));
}
}
this.addSlotToContainer(new ContainerAdvBench.SlotPlan(new ContainerAdvBench.InventorySubUpdate(td, 9, 1), 0, 17, 36));
this.slotCraft = new SlotCraftRefill(inv.player, this.craftMatrix, this.craftResult, td, this, 0, 143, 36);
this.addSlotToContainer(this.slotCraft);
ContainerAdvBench.InventorySubUpdate ingrid = new ContainerAdvBench.InventorySubUpdate(td, 10, 18);
for(int i = 0; i < 2; ++i) {
for(int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(ingrid, j + i * 9, 8 + j * 18, 90 + i * 18));
}
}
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 140 + i * 18));
}
}
for(int i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(inv, i, 8 + i * 18, 198));
}
this.fakeInv = new InventoryCrafting(new ContainerAdvBench.ContainerNull(), 3, 3);
this.onCraftMatrixChanged(this.craftMatrix);
}
public void putStackInSlot(int num, ItemStack ist) {
super.putStackInSlot(num, ist);
}
public static ItemStack[] getShadowItems(ItemStack ist) {
if (ist.stackTagCompound == null) {
return null;
} else {
NBTTagList require = ist.stackTagCompound.getTagList("requires", 10);
if (require == null) {
return null;
} else {
ItemStack[] tr = new ItemStack[9];
for(int i = 0; i < require.tagCount(); ++i) {
NBTTagCompound item = require.getCompoundTagAt(i);
ItemStack is2 = ItemStack.loadItemStackFromNBT(item);
byte sl = item.getByte("Slot");
if (sl >= 0 && sl < 9) {
tr[sl] = is2;
}
}
return tr;
}
}
}
public boolean canInteractWith(EntityPlayer player) {
return this.tileAdvBench.isUseableByPlayer(player);
}
public ItemStack[] getPlanItems() {
ItemStack plan = this.tileAdvBench.getStackInSlot(9);
return plan == null ? null : getShadowItems(plan);
}
public int getSatisfyMask() {
ItemStack plan = this.tileAdvBench.getStackInSlot(9);
ItemStack[] items = null;
if (plan != null) {
items = getShadowItems(plan);
}
int bits = 0;
for(int i = 0; i < 9; ++i) {
ItemStack test = this.tileAdvBench.getStackInSlot(i);
if (test != null) {
bits |= 1 << i;
} else if (items == null || items[i] == null) {
bits |= 1 << i;
}
}
if (bits == 511) {
return 511;
} else {
for(int var9 = 0; var9 < 18; ++var9) {
ItemStack test = this.tileAdvBench.getStackInSlot(10 + var9);
if (test != null && test.stackSize != 0) {
int sc = test.stackSize;
for(int j = 0; j < 9; ++j) {
if ((bits & 1 << j) <= 0) {
ItemStack st = this.tileAdvBench.getStackInSlot(j);
if (st == null) {
st = items[j];
if (st != null && CoreLib.matchItemStackOre(st, test)) {
bits |= 1 << j;
if (--sc == 0) {
break;
}
}
}
}
}
}
}
return bits;
}
}
private int findMatch(ItemStack a) {
for(int i = 0; i < 18; ++i) {
ItemStack test = this.tileAdvBench.getStackInSlot(10 + i);
if (test != null && test.stackSize != 0 && CoreLib.matchItemStackOre(a, test)) {
return 10 + i;
}
}
return -1;
}
public void onCraftMatrixChanged(IInventory iinventory) {
ItemStack plan = this.tileAdvBench.getStackInSlot(9);
ItemStack[] items = null;
if (plan != null) {
items = getShadowItems(plan);
}
for(int i = 0; i < 9; ++i) {
ItemStack tos = this.tileAdvBench.getStackInSlot(i);
if (tos == null && items != null && items[i] != null) {
int j = this.findMatch(items[i]);
if (j > 0) {
tos = this.tileAdvBench.getStackInSlot(j);
}
}
this.fakeInv.setInventorySlotContents(i, tos);
}
this.satisfyMask = this.getSatisfyMask();
if (this.satisfyMask == 511) {
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.fakeInv, this.tileAdvBench.getWorldObj()));
} else {
this.craftResult.setInventorySlotContents(0, (ItemStack)null);
}
}
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
ItemStack itemstack = null;
Slot slot = (Slot)super.inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i == 10) {
this.mergeCrafting(player, slot, 29, 65);
return null;
}
if (i < 9) {
if (!this.mergeItemStack(itemstack1, 11, 29, false)) {
return null;
}
} else if (i < 29) {
if (!this.mergeItemStack(itemstack1, 29, 65, true)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 11, 29, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack)null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, itemstack1);
}
return itemstack;
}
protected boolean canFit(ItemStack ist, int st, int ed) {
int ms = 0;
for(int i = st; i < ed; ++i) {
Slot slot = (Slot)super.inventorySlots.get(i);
ItemStack is2 = slot.getStack();
if (is2 == null) {
return true;
}
if (CoreLib.compareItemStack(is2, ist) == 0) {
ms += is2.getMaxStackSize() - is2.stackSize;
if (ms >= ist.stackSize) {
return true;
}
}
}
return false;
}
protected void fitItem(ItemStack ist, int st, int ed) {
if (ist.isStackable()) {
for(int i = st; i < ed; ++i) {
Slot slot = (Slot)super.inventorySlots.get(i);
ItemStack is2 = slot.getStack();
if (is2 != null && CoreLib.compareItemStack(is2, ist) == 0) {
int n = Math.min(ist.stackSize, ist.getMaxStackSize() - is2.stackSize);
if (n != 0) {
ist.stackSize -= n;
is2.stackSize += n;
slot.onSlotChanged();
if (ist.stackSize == 0) {
return;
}
}
}
}
}
for(int i = st; i < ed; ++i) {
Slot slot = (Slot)super.inventorySlots.get(i);
ItemStack is2 = slot.getStack();
if (is2 == null) {
slot.putStack(ist);
slot.onSlotChanged();
return;
}
}
}
protected void mergeCrafting(EntityPlayer player, Slot cslot, int st, int ed) {
int cc = 0;
ItemStack ist = cslot.getStack();
if (ist != null && ist.stackSize != 0) {
ItemStack craftas = ist.copy();
int mss = craftas.getMaxStackSize();
if (mss == 1) {
mss = 16;
}
do {
if (!this.canFit(ist, st, ed)) {
return;
}
cc += ist.stackSize;
this.fitItem(ist, st, ed);
cslot.onPickupFromSlot(player, ist);
if (cc >= mss) {
return;
}
if (this.slotCraft.isLastUse()) {
return;
}
ist = cslot.getStack();
if (ist == null || ist.stackSize == 0) {
return;
}
} while(CoreLib.compareItemStack(ist, craftas) == 0);
}
}
@Override
public void handleGuiEvent(PacketGuiEvent.GuiMessageEvent message) {
if (this.tileAdvBench.getWorldObj() != null && !this.tileAdvBench.getWorldObj().isRemote) {
try {
if (message.eventId == 1) {
ItemStack blank = this.tileAdvBench.getStackInSlot(9);
if (blank != null && blank.getItem() == RedPowerBase.itemPlanBlank) {
ItemStack plan = new ItemStack(RedPowerBase.itemPlanFull);
plan.stackTagCompound = new NBTTagCompound();
NBTTagCompound result = new NBTTagCompound();
this.craftResult.getStackInSlot(0).writeToNBT(result);
plan.stackTagCompound.setTag("result", result);
NBTTagList requires = new NBTTagList();
for(int i = 0; i < 9; ++i) {
ItemStack is1 = this.craftMatrix.getStackInSlot(i);
if (is1 != null) {
ItemStack ist = CoreLib.copyStack(is1, 1);
NBTTagCompound item = new NBTTagCompound();
ist.writeToNBT(item);
item.setByte("Slot", (byte)i);
requires.appendTag(item);
}
}
plan.stackTagCompound.setTag("requires", requires);
this.tileAdvBench.setInventorySlotContents(9, plan);
}
}
} catch (Throwable var10) {
}
}
}
public static class ContainerNull extends Container {
public boolean canInteractWith(EntityPlayer player) {
return false;
}
public void onCraftMatrixChanged(IInventory inv) {
}
public ItemStack slotClick(int a, int b, int c, EntityPlayer player) {
return !this.canInteractWith(player) ? null : super.slotClick(a, b, c, player);
}
}
public class InventorySubUpdate implements IInventory {
int size;
int start;
IInventory parent;
public InventorySubUpdate(IInventory par, int st, int sz) {
this.parent = par;
this.start = st;
this.size = sz;
}
public int getSizeInventory() {
return this.size;
}
public ItemStack getStackInSlot(int idx) {
return this.parent.getStackInSlot(idx + this.start);
}
public ItemStack decrStackSize(int idx, int num) {
ItemStack tr = this.parent.decrStackSize(idx + this.start, num);
if (tr != null) {
ContainerAdvBench.this.onCraftMatrixChanged(this);
}
return tr;
}
public ItemStack getStackInSlotOnClosing(int idx) {
return this.parent.getStackInSlotOnClosing(idx + this.start);
}
public void setInventorySlotContents(int idx, ItemStack ist) {
this.parent.setInventorySlotContents(idx + this.start, ist);
ContainerAdvBench.this.onCraftMatrixChanged(this);
}
public String getInventoryName() {
return this.parent.getInventoryName();
}
public int getInventoryStackLimit() {
return this.parent.getInventoryStackLimit();
}
public void markDirty() {
ContainerAdvBench.this.onCraftMatrixChanged(this);
this.parent.markDirty();
}
public boolean isUseableByPlayer(EntityPlayer player) {
return false;
}
public void openInventory() {
}
public void closeInventory() {
}
public boolean hasCustomInventoryName() {
return true;
}
public boolean isItemValidForSlot(int slotID, ItemStack itemStack) {
return true;
}
}
public static class SlotPlan extends Slot {
public SlotPlan(IInventory inv, int i, int j, int k) {
super(inv, i, j, k);
}
public boolean isItemValid(ItemStack ist) {
return ist.getItem() == RedPowerBase.itemPlanBlank || ist.getItem() == RedPowerBase.itemPlanFull;
}
public int getSlotStackLimit() {
return 1;
}
}
}

View File

@ -0,0 +1,115 @@
package com.eloraam.redpower.base;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerAlloyFurnace extends Container {
private TileAlloyFurnace tileFurnace;
public int totalburn = 0;
public int burntime = 0;
public int cooktime = 0;
public ContainerAlloyFurnace(InventoryPlayer inv, TileAlloyFurnace td) {
this.tileFurnace = td;
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 3; ++j) {
this.addSlotToContainer(new Slot(td, j + i * 3, 48 + j * 18, 17 + i * 18));
}
}
this.addSlotToContainer(new Slot(td, 9, 17, 42));
this.addSlotToContainer(new SlotAlloyFurnace(inv.player, td, 10, 141, 35));
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for(int i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
}
}
public ItemStack slotClick(int a, int b, int c, EntityPlayer player) {
return !this.canInteractWith(player) ? null : super.slotClick(a, b, c, player);
}
public boolean canInteractWith(EntityPlayer player) {
return this.tileFurnace.isUseableByPlayer(player);
}
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
ItemStack itemstack = null;
Slot slot = (Slot)super.inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < 11) {
if (!this.mergeItemStack(itemstack1, 11, 47, true)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 0, 9, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, itemstack1);
}
return itemstack;
}
public void detectAndSendChanges() {
super.detectAndSendChanges();
for(ICrafting ic : (List<ICrafting> )super.crafters) {
if (this.totalburn != this.tileFurnace.totalburn) {
ic.sendProgressBarUpdate(this, 0, this.tileFurnace.totalburn);
}
if (this.burntime != this.tileFurnace.burntime) {
ic.sendProgressBarUpdate(this, 1, this.tileFurnace.burntime);
}
if (this.cooktime != this.tileFurnace.cooktime) {
ic.sendProgressBarUpdate(this, 2, this.tileFurnace.cooktime);
}
}
this.totalburn = this.tileFurnace.totalburn;
this.cooktime = this.tileFurnace.cooktime;
this.burntime = this.tileFurnace.burntime;
}
public void updateProgressBar(int id, int value) {
switch(id) {
case 0:
this.tileFurnace.totalburn = value;
break;
case 1:
this.tileFurnace.burntime = value;
break;
case 2:
this.tileFurnace.cooktime = value;
}
}
}

View File

@ -0,0 +1,107 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.SlotLocked;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerBag extends Container {
private ItemStack itemBag;
private int hotbarIndex;
public ContainerBag(InventoryPlayer inv, IInventory bag, ItemStack stack) {
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 9; ++j) {
this.addSlotToContainer(new ContainerBag.SlotBag(bag, j + i * 9, 8 + j * 18, 18 + i * 18));
}
}
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 86 + i * 18));
}
}
for(int i = 0; i < 9; ++i) {
if (inv.currentItem == i) {
this.addSlotToContainer(new SlotLocked(inv, i, 8 + i * 18, 144));
} else {
this.addSlotToContainer(new Slot(inv, i, 8 + i * 18, 144));
}
}
this.itemBag = stack;
this.hotbarIndex = inv.currentItem;
}
public boolean canInteractWith(EntityPlayer player) {
return player.worldObj.isRemote || this.itemBag == player.getHeldItem();
}
public ItemStack transferStackInSlot(EntityPlayer player, int slotId) {
if (!player.worldObj.isRemote && this.itemBag != player.getHeldItem()) {
player.closeScreen();
return null;
} else {
ItemStack result = null;
Slot slot = (Slot)super.inventorySlots.get(slotId);
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
if (slotStack.getItem() instanceof ItemBag) {
return null;
}
result = slotStack.copy();
if (slotId < 27) {
if (!this.mergeItemStack(slotStack, 27, 63, true)) {
return null;
}
} else if (!this.mergeItemStack(slotStack, 0, 27, false)) {
return null;
}
if (slotStack.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (slotStack.stackSize == result.stackSize) {
return null;
}
slot.onPickupFromSlot(player, slotStack);
}
return result;
}
}
public ItemStack slotClick(int slotId, int dragModeOrBtn, int mode, EntityPlayer player) {
if (!this.canInteractWith(player)) {
return null;
} else {
if (mode == 2 && dragModeOrBtn >= 0 && dragModeOrBtn < 9) {
Slot hotbarSlot = this.getSlot(54 + dragModeOrBtn);
if (hotbarSlot instanceof SlotLocked) {
return null;
}
}
return super.slotClick(slotId, dragModeOrBtn, mode, player);
}
}
public static class SlotBag extends Slot {
public SlotBag(IInventory inv, int index, int x, int y) {
super(inv, index, x, y);
}
public boolean isItemValid(ItemStack stack) {
return !(stack.getItem() instanceof ItemBag);
}
}
}

View File

@ -0,0 +1,66 @@
package com.eloraam.redpower.base;
import java.util.List;
import com.eloraam.redpower.core.IHandleGuiEvent;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class ContainerBusId extends Container implements IHandleGuiEvent {
private IRedbusConnectable rbConn;
private int addr = 0;
public ContainerBusId(IInventory inv, IRedbusConnectable irc) {
this.rbConn = irc;
}
public ItemStack slotClick(int a, int b, int c, EntityPlayer player) {
return !this.canInteractWith(player) ? null : super.slotClick(a, b, c, player);
}
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
return null;
}
public void detectAndSendChanges() {
super.detectAndSendChanges();
for(ICrafting ic : (List<ICrafting>)super.crafters) {
if (this.rbConn.rbGetAddr() != this.addr) {
ic.sendProgressBarUpdate(this, 0, this.rbConn.rbGetAddr());
}
}
this.addr = this.rbConn.rbGetAddr();
}
public void updateProgressBar(int id, int value) {
switch(id) {
case 0:
this.rbConn.rbSetAddr(value);
return;
}
}
@Override
public void handleGuiEvent(PacketGuiEvent.GuiMessageEvent message) {
try {
if (message.eventId != 1) {
return;
}
this.rbConn.rbSetAddr(message.parameters[0]);
} catch (Throwable var3) {
}
}
}

View File

@ -0,0 +1,114 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.RedPowerCore;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiAdvBench extends GuiContainer {
private static final ResourceLocation res = new ResourceLocation("rpbase", "textures/gui/advbench.png");
private TileAdvBench bench;
public GuiAdvBench(InventoryPlayer pli, TileAdvBench td) {
super(new ContainerAdvBench(pli, td));
this.bench = td;
super.ySize = 222;
}
public GuiAdvBench(Container cn) {
super(cn);
super.ySize = 222;
}
protected void drawGuiContainerForegroundLayer(int p1, int p2) {
super.fontRendererObj.drawString(I18n.format("tile.rpabench.name", new Object[0]), 60, 6, 4210752);
super.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, super.ySize - 96 + 2, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float f, int p1, int p2) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(res);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
ItemStack plan = super.inventorySlots.getSlot(9).getStack();
ItemStack craft = super.inventorySlots.getSlot(10).getStack();
if (plan != null && craft != null && plan.getItem() == RedPowerBase.itemPlanBlank) {
this.drawTexturedModalRect(j + 18, k + 55, 176, 0, 14, 14);
}
if (plan != null && plan.getItem() == RedPowerBase.itemPlanFull) {
ContainerAdvBench cont = (ContainerAdvBench)super.inventorySlots;
ItemStack[] ist = ContainerAdvBench.getShadowItems(plan);
RenderHelper.enableGUIStandardItemLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(32826);
GL11.glEnable(2896);
GL11.glEnable(2929);
for(int n = 0; n < 9; ++n) {
if (ist[n] != null) {
Slot sl = super.inventorySlots.getSlot(n);
if (sl.getStack() == null) {
int slx = sl.xDisplayPosition + j;
int sly = sl.yDisplayPosition + k;
GuiScreen.itemRender.renderItemIntoGUI(super.fontRendererObj, super.mc.renderEngine, ist[n], slx, sly);
GuiScreen.itemRender.renderItemOverlayIntoGUI(super.fontRendererObj, super.mc.renderEngine, ist[n], slx, sly);
}
}
}
GL11.glDisable(2896);
GL11.glDisable(2929);
GL11.glEnable(3042);
super.mc.renderEngine.bindTexture(res);
for(int n = 0; n < 9; ++n) {
if (ist[n] != null) {
Slot sl = super.inventorySlots.getSlot(n);
if (sl.getStack() == null) {
int slx = sl.xDisplayPosition;
int sly = sl.yDisplayPosition;
if ((cont.satisfyMask & 1 << n) > 0) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
} else {
GL11.glColor4f(1.0F, 0.1F, 0.1F, 0.6F);
}
this.drawTexturedModalRect(j + slx, k + sly, slx, sly, 16, 16);
}
}
}
GL11.glDisable(3042);
}
}
protected void mouseClicked(int i, int j, int k) {
int x = i - (super.width - super.xSize) / 2;
int y = j - (super.height - super.ySize) / 2;
if (x >= 18 && y >= 55 && x <= 32 && y <= 69) {
ItemStack plan = super.inventorySlots.getSlot(9).getStack();
ItemStack craft = super.inventorySlots.getSlot(10).getStack();
if (plan == null || craft == null || plan.getItem() != RedPowerBase.itemPlanBlank) {
return;
}
RedPowerCore.sendPacketToServer(new PacketGuiEvent.GuiMessageEvent(1, super.inventorySlots.windowId));
}
super.mouseClicked(i, j, k);
}
}

View File

@ -0,0 +1,42 @@
package com.eloraam.redpower.base;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiAlloyFurnace extends GuiContainer {
private static final ResourceLocation res = new ResourceLocation("rpbase", "textures/gui/afurnacegui.png");
private TileAlloyFurnace furnace;
public GuiAlloyFurnace(InventoryPlayer pli, TileAlloyFurnace td) {
super(new ContainerAlloyFurnace(pli, td));
this.furnace = td;
}
public GuiAlloyFurnace(Container cn) {
super(cn);
}
protected void drawGuiContainerForegroundLayer(int p1, int p2) {
super.fontRendererObj.drawString(I18n.format("tile.rpafurnace.name", new Object[0]), 60, 6, 4210752);
super.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, super.ySize - 96 + 2, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float f, int p1, int p2) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(res);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
if (this.furnace.burntime > 0) {
int i1 = this.furnace.getBurnScaled(12);
this.drawTexturedModalRect(j + 17, k + 25 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
}
int i1 = this.furnace.getCookScaled(24);
this.drawTexturedModalRect(j + 107, k + 34, 176, 14, i1 + 1, 16);
}
}

View File

@ -0,0 +1,36 @@
package com.eloraam.redpower.base;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiBag extends GuiContainer {
private static ResourceLocation res = new ResourceLocation("rpbase", "textures/gui/baggui.png");
public GuiBag(InventoryPlayer pli, IInventory td) {
super(new ContainerBag(pli, td, null));
super.ySize = 167;
}
public GuiBag(Container cn) {
super(cn);
super.ySize = 167;
}
protected void drawGuiContainerForegroundLayer(int p1, int p2) {
super.fontRendererObj.drawString(I18n.format("item.rpBag.name", new Object[0]), 8, 6, 4210752);
super.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, super.ySize - 94 + 2, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(res);
int halfWidth = (super.width - super.xSize) / 2;
int halfHeight = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(halfWidth, halfHeight, 0, 0, super.xSize, super.ySize);
}
}

View File

@ -0,0 +1,76 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerCore;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiBusId extends GuiContainer {
private static final ResourceLocation res = new ResourceLocation("rpbase", "textures/gui/idgui.png");
private IRedbusConnectable rbConn;
private TileEntity tile;
public GuiBusId(InventoryPlayer pli, IRedbusConnectable irc, TileEntity tile) {
super(new ContainerBusId(pli, irc));
this.rbConn = irc;
this.tile = tile;
super.ySize = 81;
super.xSize = 123;
}
public GuiBusId(Container cn) {
super(cn);
super.ySize = 81;
super.xSize = 123;
}
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.fontRendererObj.drawString(I18n.format("gui.busid", new Object[0]), 32, 6, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(res);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
int bits = this.rbConn.rbGetAddr() & 0xFF;
for(int n = 0; n < 8; ++n) {
if ((bits & 1 << n) != 0) {
this.drawTexturedModalRect(j + 16 + n * 12, k + 25, 123, 0, 8, 16);
}
}
this.drawCenteredString(super.fontRendererObj, String.format("ID: %d", bits), super.width / 2, k + 60, -1);
}
private void sendAddr() {
if (super.mc.theWorld.isRemote) {
RedPowerCore.sendPacketToServer(new PacketGuiEvent.GuiMessageEvent(1, super.inventorySlots.windowId, (byte)this.rbConn.rbGetAddr()));
}
}
protected void mouseClicked(int mouseX, int mouseY, int button) {
int x = mouseX - (super.width - super.xSize) / 2;
int y = mouseY - (super.height - super.ySize) / 2;
if (y >= 25 && y <= 41) {
for(int n = 0; n < 8; ++n) {
if (x >= 16 + n * 12 && x <= 24 + n * 12) {
this.rbConn.rbSetAddr(this.rbConn.rbGetAddr() ^ 1 << n);
this.sendAddr();
return;
}
}
}
super.mouseClicked(mouseX, mouseY, button);
}
}

View File

@ -0,0 +1,48 @@
package com.eloraam.redpower.base;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
public class InventorySubCraft extends InventoryCrafting {
private Container eventHandler;
private IInventory parent;
public InventorySubCraft(Container container, IInventory par) {
super(container, 3, 3);
this.parent = par;
this.eventHandler = container;
}
public int getSizeInventory() {
return 9;
}
public ItemStack getStackInSlot(int i) {
return i >= 9 ? null : this.parent.getStackInSlot(i);
}
public ItemStack getStackInRowAndColumn(int i, int j) {
if (i >= 0 && i < 3) {
int k = i + j * 3;
return this.getStackInSlot(k);
} else {
return null;
}
}
public ItemStack decrStackSize(int i, int j) {
ItemStack tr = this.parent.decrStackSize(i, j);
if (tr != null) {
this.eventHandler.onCraftMatrixChanged(this);
}
return tr;
}
public void setInventorySlotContents(int i, ItemStack ist) {
this.parent.setInventorySlotContents(i, ist);
this.eventHandler.onCraftMatrixChanged(this);
}
}

View File

@ -0,0 +1,185 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class ItemBag extends Item {
private IIcon[] icons = new IIcon[16];
public ItemBag() {
this.setMaxStackSize(1);
this.setHasSubtypes(true);
this.setUnlocalizedName("rpBag");
this.setCreativeTab(CreativeTabs.tabMisc);
}
public static IInventory getBagInventory(ItemStack ist, EntityPlayer player) {
return !(ist.getItem() instanceof ItemBag) ? null : ((ItemBag)ist.getItem()).new InventoryBag(ist, player);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister registerer) {
for(int color = 0; color < 16; ++color) {
this.icons[color] = registerer.registerIcon("rpbase:bag/" + color);
}
}
public int getMaxItemUseDuration(ItemStack ist) {
return 1;
}
public IIcon getIconFromDamage(int meta) {
return this.icons[meta % this.icons.length];
}
public ItemStack onItemRightClick(ItemStack ist, World world, EntityPlayer player) {
if (!world.isRemote && !player.isSneaking()) {
player.openGui(RedPowerBase.instance, 4, world, 0, 0, 0);
}
return ist;
}
public class InventoryBag implements IInventory {
ItemStack bagitem;
ItemStack[] items;
EntityPlayer player;
InventoryBag(ItemStack ist, EntityPlayer host) {
this.bagitem = ist;
this.player = host;
this.unpackInventory();
}
private void unpackInventory() {
this.items = new ItemStack[27];
if (this.bagitem.stackTagCompound != null) {
NBTTagList list = this.bagitem.stackTagCompound.getTagList("contents", 10);
for(int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound item = list.getCompoundTagAt(i);
byte slt = item.getByte("Slot");
if (slt < 27) {
this.items[slt] = ItemStack.loadItemStackFromNBT(item);
}
}
}
}
private void packInventory() {
if (this.bagitem.stackTagCompound == null) {
this.bagitem.setTagCompound(new NBTTagCompound());
}
NBTTagList contents = new NBTTagList();
for(int i = 0; i < 27; ++i) {
if (this.items[i] != null) {
NBTTagCompound cpd = new NBTTagCompound();
this.items[i].writeToNBT(cpd);
cpd.setByte("Slot", (byte)i);
contents.appendTag(cpd);
}
}
this.bagitem.stackTagCompound.setTag("contents", contents);
}
public int getSizeInventory() {
return 27;
}
public ItemStack getStackInSlot(int slot) {
return this.items[slot];
}
public ItemStack decrStackSize(int slot, int num) {
if (this.bagitem != this.player.getHeldItem()) {
this.markDirty();
this.player.closeScreen();
return null;
} else if (this.items[slot] == null) {
return null;
} else if (this.items[slot].stackSize <= num) {
ItemStack tr = this.items[slot];
this.items[slot] = null;
this.markDirty();
return tr;
} else {
ItemStack tr = this.items[slot].splitStack(num);
if (this.items[slot].stackSize == 0) {
this.items[slot] = null;
}
this.markDirty();
return tr;
}
}
public ItemStack getStackInSlotOnClosing(int slot) {
if (this.items[slot] == null) {
return null;
} else {
ItemStack tr = this.items[slot];
this.items[slot] = null;
return tr;
}
}
public void setInventorySlotContents(int slot, ItemStack ist) {
if (this.bagitem != this.player.getHeldItem()) {
this.markDirty();
this.player.closeScreen();
} else {
this.items[slot] = ist;
if (ist != null && ist.stackSize > this.getInventoryStackLimit()) {
ist.stackSize = this.getInventoryStackLimit();
}
}
}
public String getInventoryName() {
return "item.rpBag.name";
}
public int getInventoryStackLimit() {
return 64;
}
public void markDirty() {
this.packInventory();
}
public boolean isUseableByPlayer(EntityPlayer player) {
return this.bagitem == this.player.getHeldItem();
}
public void openInventory() {
}
public void closeInventory() {
}
public boolean hasCustomInventoryName() {
return false;
}
public boolean isItemValidForSlot(int slotID, ItemStack stack) {
return this.bagitem != null && stack.getItem() != ItemBag.this;
}
}
}

View File

@ -0,0 +1,18 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.ItemPartialCraft;
import net.minecraft.creativetab.CreativeTabs;
public class ItemDrawplate extends ItemPartialCraft {
public ItemDrawplate() {
this.setCreativeTab(CreativeTabs.tabTools);
}
public boolean isFull3D() {
return true;
}
public boolean shouldRotateAroundWhenRendering() {
return true;
}
}

View File

@ -0,0 +1,31 @@
package com.eloraam.redpower.base;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemDyeIndigo extends Item {
public ItemDyeIndigo() {
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setUnlocalizedName("dyeIndigo");
this.setTextureName("rpbase:dyeIndigo");
this.setCreativeTab(CreativeTabs.tabMaterials);
}
public boolean itemInteractionForEntity(ItemStack ist, EntityPlayer player, EntityLivingBase entity) {
if (ist.getItemDamage() == 0 && entity instanceof EntitySheep) {
EntitySheep entitysheep = (EntitySheep)entity;
if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != 11) {
entitysheep.setFleeceColor(11);
--ist.stackSize;
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,25 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.ItemPartialCraft;
import net.minecraft.creativetab.CreativeTabs;
public class ItemHandsaw extends ItemPartialCraft {
private int sharp;
public ItemHandsaw(int sh) {
this.sharp = sh;
this.setCreativeTab(CreativeTabs.tabTools);
}
public boolean isFull3D() {
return true;
}
public boolean shouldRotateAroundWhenRendering() {
return true;
}
public int getSharpness() {
return this.sharp;
}
}

View File

@ -0,0 +1,276 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CoverLib;
import com.eloraam.redpower.core.CreativeExtraTabs;
import com.eloraam.redpower.core.ICoverable;
import com.eloraam.redpower.core.IMicroPlacement;
import com.eloraam.redpower.core.RedPowerLib;
import com.eloraam.redpower.core.WorldCoord;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
public class ItemMicro extends ItemBlock {
private IMicroPlacement[] placers = new IMicroPlacement[256];
public ItemMicro(Block block) {
super(block);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
private boolean useCover(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side) {
MovingObjectPosition pos = CoreLib.retraceBlock(world, player, x, y, z);
if (pos == null) {
return false;
} else if (pos.typeOfHit != MovingObjectType.BLOCK) {
return false;
} else {
pos = CoverLib.getPlacement(world, pos, ist.getItemDamage());
if (pos == null) {
return false;
} else {
Block oldBlock = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if (world.canPlaceEntityOnSide(oldBlock, pos.blockX, pos.blockY, pos.blockZ, false, side, player, ist)) {
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, RedPowerBase.blockMicro, 0, 3);
}
TileEntity te = world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
Block newBlock = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
int newMeta = world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
if (!(te instanceof ICoverable)) {
return false;
} else {
ICoverable icv = (ICoverable)te;
PlayerInteractEvent event = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, pos.blockX, pos.blockY, pos.blockZ, side, world);
if (!MinecraftForge.EVENT_BUS.post(event)) {
NBTTagCompound nbt = new NBTTagCompound();
te.writeToNBT(nbt);
BlockSnapshot snapshot = new BlockSnapshot(world, pos.blockX, pos.blockY, pos.blockZ, newBlock, newMeta, nbt);
PlaceEvent plvt = new PlaceEvent(snapshot, oldBlock, player);
if (!MinecraftForge.EVENT_BUS.post(plvt)) {
if (icv.tryAddCover(pos.subHit, CoverLib.damageToCoverValue(ist.getItemDamage()))) {
if (!player.capabilities.isCreativeMode) {
--ist.stackSize;
}
CoreLib.placeNoise(world, pos.blockX, pos.blockY, pos.blockZ, CoverLib.getBlock(ist.getItemDamage() & 0xFF));
RedPowerLib.updateIndirectNeighbors(world, pos.blockX, pos.blockY, pos.blockZ, RedPowerBase.blockMicro);
world.markBlockForUpdate(pos.blockX, pos.blockY, pos.blockZ);
return true;
}
return false;
}
}
return false;
}
}
}
}
@SideOnly(Side.CLIENT)
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack ist) {
return true;
}
public boolean onItemUse(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side, float xp, float yp, float zp) {
return player != null && !player.isSneaking() && this.itemUseShared(ist, player, world, x, y, z, side);
}
public boolean onItemUseFirst(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side, float xp, float yp, float zp) {
return !world.isRemote && player.isSneaking() && this.itemUseShared(ist, player, world, x, y, z, side);
}
private boolean itemUseShared(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side) {
int hb = ist.getItemDamage();
hb >>= 8;
return hb != 0 && (hb < 16 || hb > 45)
? this.placers[hb] != null && this.placers[hb].onPlaceMicro(ist, player, world, new WorldCoord(x, y, z), side)
: this.useCover(ist, player, world, x, y, z, side);
}
private String getMicroName(int hb) {
switch(hb) {
case 0:
return "rpcover";
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
default:
return null;
case 16:
return "rppanel";
case 17:
return "rpslab";
case 18:
return "rpcovc";
case 19:
return "rppanc";
case 20:
return "rpslabc";
case 21:
return "rpcovs";
case 22:
return "rppans";
case 23:
return "rpslabs";
case 24:
return "rphcover";
case 25:
return "rphpanel";
case 26:
return "rphslab";
case 27:
return "rpcov3";
case 28:
return "rpcov5";
case 29:
return "rpcov6";
case 30:
return "rpcov7";
case 31:
return "rphcov3";
case 32:
return "rphcov5";
case 33:
return "rphcov6";
case 34:
return "rphcov7";
case 35:
return "rpcov3c";
case 36:
return "rpcov5c";
case 37:
return "rpcov6c";
case 38:
return "rpcov7c";
case 39:
return "rpcov3s";
case 40:
return "rpcov5s";
case 41:
return "rpcov6s";
case 42:
return "rpcov7s";
case 43:
return "rppole1";
case 44:
return "rppole2";
case 45:
return "rppole3";
}
}
public String getUnlocalizedName(ItemStack ist) {
int hb = ist.getItemDamage();
int lb = hb & 0xFF;
hb >>= 8;
String stub = this.getMicroName(hb);
if (stub != null) {
String name = CoverLib.getName(lb);
if (name == null) {
throw new IndexOutOfBoundsException();
} else {
return "tile." + stub + "." + name;
}
} else if (this.placers[hb] == null) {
throw new IndexOutOfBoundsException();
} else {
String name = this.placers[hb].getMicroName(hb, lb);
if (name == null) {
throw new IndexOutOfBoundsException();
} else {
return name;
}
}
}
public void registerPlacement(int md, IMicroPlacement imp) {
this.placers[md] = imp;
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item id, CreativeTabs tab, List list) {
if (tab != CreativeExtraTabs.tabWires && tab != CreativeExtraTabs.tabMachine) {
if (tab == CreativeExtraTabs.tabMicros) {
for(int i = 0; i < 255; ++i) {
String stub = CoverLib.getName(i);
if (stub != null) {
list.add(new ItemStack(RedPowerBase.blockMicro, 1, i));
}
}
for(int i = 1; i < 255; ++i) {
String stub = this.getMicroName(i);
if (stub != null) {
list.add(new ItemStack(RedPowerBase.blockMicro, 1, i << 8));
}
}
for(int i = 1; i < 255; ++i) {
String stub = this.getMicroName(i);
if (stub != null) {
list.add(new ItemStack(RedPowerBase.blockMicro, 1, i << 8 | 2));
}
}
for(int i = 1; i < 255; ++i) {
String stub = this.getMicroName(i);
if (stub != null) {
list.add(new ItemStack(RedPowerBase.blockMicro, 1, i << 8 | 23));
}
}
for(int i = 1; i < 255; ++i) {
String stub = this.getMicroName(i);
if (stub != null) {
list.add(new ItemStack(RedPowerBase.blockMicro, 1, i << 8 | 26));
}
}
}
} else {
for(int i = 0; i < 255; ++i) {
if (this.placers[i] != null) {
this.placers[i].addCreativeItems(i, tab, list);
}
}
}
}
public CreativeTabs[] getCreativeTabs() {
return new CreativeTabs[]{CreativeExtraTabs.tabWires, CreativeExtraTabs.tabMicros, CreativeExtraTabs.tabMachine};
}
}

View File

@ -0,0 +1,74 @@
package com.eloraam.redpower.base;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class ItemPlan extends Item {
public ItemPlan() {
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setUnlocalizedName("planFull");
this.setTextureName("rpbase:planFull");
this.setMaxStackSize(1);
}
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(ItemStack ist) {
if (ist.stackTagCompound == null) {
return super.getItemStackDisplayName(ist);
} else if (!ist.stackTagCompound.hasKey("result")) {
return super.getItemStackDisplayName(ist);
} else {
NBTTagCompound res = ist.stackTagCompound.getCompoundTag("result");
ItemStack result = ItemStack.loadItemStackFromNBT(res);
return result.getItem().getItemStackDisplayName(result) + " Plan";
}
}
public void addInformation(ItemStack ist, EntityPlayer player, List lines, boolean par4) {
if (ist.stackTagCompound != null) {
NBTTagList require = ist.stackTagCompound.getTagList("requires", 10);
if (require != null) {
HashMap<HashMap<Item, Integer>, Integer> counts = new HashMap();
for(int i = 0; i < require.tagCount(); ++i) {
NBTTagCompound kv = require.getCompoundTagAt(i);
ItemStack li = ItemStack.loadItemStackFromNBT(kv);
HashMap<Item, Integer> i2d = new HashMap();
i2d.put(li.getItem(), li.getItemDamage());
Integer lc = (Integer)counts.get(i2d);
if (lc == null) {
lc = 0;
}
counts.put(i2d, lc + 1);
}
for(Entry<HashMap<Item, Integer>, Integer> entry : counts.entrySet()) {
HashMap<Item, Integer> keySet = (HashMap)entry.getKey();
ItemStack itemStack = new ItemStack((Item)keySet.keySet().iterator().next(), 1, keySet.values().iterator().next());
lines.add(entry.getValue() + " x " + itemStack.getItem().getItemStackDisplayName(itemStack));
}
}
}
}
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack ist) {
return EnumRarity.rare;
}
public boolean getShareTag() {
return true;
}
}

View File

@ -0,0 +1,105 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.control.TileCPU;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.IRotatable;
import com.google.common.collect.Multimap;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class ItemScrewdriver extends Item {
public ItemScrewdriver() {
this.setMaxDamage(200);
this.setMaxStackSize(1);
this.setCreativeTab(CreativeTabs.tabTools);
this.setUnlocalizedName("screwdriver");
this.setTextureName("rpbase:screwdriver");
}
public boolean hitEntity(ItemStack ist, EntityLivingBase ent, EntityLivingBase hitter) {
ist.damageItem(8, hitter);
return true;
}
public boolean onItemUseFirst(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side, float xp, float yp, float zp) {
if (!world.isRemote) {
boolean sec = false;
if (player != null && player.isSneaking()) {
sec = true;
}
Block bid = world.getBlock(x, y, z);
int md = world.getBlockMetadata(x, y, z);
if (bid == Blocks.unpowered_repeater || bid == Blocks.powered_repeater) {
world.setBlock(x, y, z, bid, md & 12 | md + 1 & 3, 3);
ist.damageItem(1, player);
return true;
} else if (bid == Blocks.dispenser) {
md = md & 3 ^ md >> 2;
md += 2;
world.setBlock(x, y, z, bid, md, 3);
ist.damageItem(1, player);
return true;
} else if (bid != Blocks.piston && bid != Blocks.sticky_piston) {
if (player.isSneaking()) {
IRedbusConnectable irb = CoreLib.getTileEntity(world, x, y, z, IRedbusConnectable.class);
if (irb != null && !(irb instanceof TileCPU)) {
player.openGui(RedPowerBase.instance, 3, world, x, y, z);
return true;
}
}
IRotatable ir = CoreLib.getTileEntity(world, x, y, z, IRotatable.class);
if (ir == null) {
return false;
} else {
MovingObjectPosition mop = CoreLib.retraceBlock(world, player, x, y, z);
if (mop == null) {
return false;
} else {
int rm = ir.getPartMaxRotation(mop.subHit, sec);
if (rm == 0) {
return false;
} else {
int r = ir.getPartRotation(mop.subHit, sec);
if (++r > rm) {
r = 0;
}
ir.setPartRotation(mop.subHit, sec, r);
ist.damageItem(1, player);
return true;
}
}
}
} else {
if (++md > 5) {
md = 0;
}
world.setBlock(x, y, z, bid, md, 3);
ist.damageItem(1, player);
return true;
}
} else {
return false;
}
}
public Multimap getAttributeModifiers(ItemStack stack) {
Multimap map = super.getAttributeModifiers(stack);
map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(Item.field_111210_e, "Weapon modifier", 4.0, 0));
return map;
}
}

View File

@ -0,0 +1,66 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
public class RecipeBag implements IRecipe {
public int getRecipeSize() {
return 2;
}
public ItemStack getRecipeOutput() {
return new ItemStack(RedPowerBase.itemBag, 1, 0);
}
private ItemStack findResult(InventoryCrafting inv) {
ItemStack bag = null;
int color = -1;
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 3; ++j) {
ItemStack ist = inv.getStackInRowAndColumn(i, j);
if (ist != null) {
if (ist.getItem() instanceof ItemBag) {
if (bag != null) {
return null;
}
bag = ist;
} else {
if (ist.getItem() != Items.dye) {
return null;
}
if (color >= 0) {
return null;
}
color = 15 - ist.getItemDamage();
}
}
}
}
if (bag == null || color < 0) {
return null;
} else if (bag.getItemDamage() == color) {
return null;
} else {
bag = bag.copy();
bag.setItemDamage(color);
return bag;
}
}
public ItemStack getCraftingResult(InventoryCrafting inv) {
return this.findResult(inv).copy();
}
public boolean matches(InventoryCrafting inv, World world) {
return this.findResult(inv) != null;
}
}

View File

@ -0,0 +1,79 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderAdvBench extends RenderCustomBlock {
protected RenderContext context = new RenderContext();
public RenderAdvBench(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileAdvBench bench = (TileAdvBench)tile;
World world = bench.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.bindBlockTexture();
this.context.setDefaults();
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
this.context.setPos(x, y, z);
this.context.readGlobalLights(world, bench.xCoord, bench.yCoord, bench.zCoord);
this.context
.setIcon(
RedPowerBase.projectTableBottom,
RedPowerBase.projectTableTop,
RedPowerBase.projectTableFront,
RedPowerBase.projectTableSide,
RedPowerBase.projectTableSide,
RedPowerBase.projectTableSide
);
this.context.setSize(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
this.context.setupBox();
this.context.transform();
this.context.rotateTextures(bench.Rotation);
tess.startDrawingQuads();
this.context.renderGlobFaces(63);
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.useNormal = true;
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
this.context
.setIcon(
RedPowerBase.projectTableBottom,
RedPowerBase.projectTableTop,
RedPowerBase.projectTableSide,
RedPowerBase.projectTableSide,
RedPowerBase.projectTableSide,
RedPowerBase.projectTableFront
);
this.context.renderBox(63, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
tess.draw();
this.context.useNormal = false;
}
}

View File

@ -0,0 +1,111 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderAlloyFurnace extends RenderCustomBlock {
protected RenderContext context = new RenderContext();
public RenderAlloyFurnace(Block block) {
super(block);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
TileAlloyFurnace tb = CoreLib.getTileEntity(world, x, y, z, TileAlloyFurnace.class);
if (tb != null && tb.Active) {
float f = (float)x + 0.5F;
float f1 = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F;
float f2 = (float)z + 0.5F;
float f3 = 0.52F;
float f4 = random.nextFloat() * 0.6F - 0.3F;
switch(tb.Rotation) {
case 0:
world.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0, 0.0, 0.0);
world.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0, 0.0, 0.0);
break;
case 1:
world.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0, 0.0, 0.0);
world.spawnParticle("flame", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0, 0.0, 0.0);
break;
case 2:
world.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0, 0.0, 0.0);
world.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0, 0.0, 0.0);
break;
case 3:
world.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0, 0.0, 0.0);
world.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0, 0.0, 0.0);
}
}
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileAlloyFurnace alloyFurnace = (TileAlloyFurnace)tile;
World world = alloyFurnace.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.bindBlockTexture();
this.context.setDefaults();
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
this.context.setPos(x, y, z);
this.context.readGlobalLights(world, alloyFurnace.xCoord, alloyFurnace.yCoord, alloyFurnace.zCoord);
this.context
.setIcon(
RedPowerBase.alloyFurnaceVert,
RedPowerBase.alloyFurnaceVert,
alloyFurnace.Active ? RedPowerBase.alloyFurnaceFrontOn : RedPowerBase.alloyFurnaceFront,
RedPowerBase.alloyFurnaceSide,
RedPowerBase.alloyFurnaceSide,
RedPowerBase.alloyFurnaceSide
);
this.context.setSize(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
this.context.setupBox();
this.context.transform();
this.context.rotateTextures(alloyFurnace.Rotation);
tess.startDrawingQuads();
this.context.renderGlobFaces(63);
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.useNormal = true;
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
this.context
.setIcon(
RedPowerBase.alloyFurnaceVert,
RedPowerBase.alloyFurnaceVert,
RedPowerBase.alloyFurnaceSide,
RedPowerBase.alloyFurnaceSide,
RedPowerBase.alloyFurnaceSide,
RedPowerBase.alloyFurnaceFront
);
this.context.renderBox(63, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
tess.draw();
this.context.useNormal = false;
}
}

View File

@ -0,0 +1,45 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.AchieveLib;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotAlloyFurnace extends Slot {
private EntityPlayer thePlayer;
int totalCrafted;
public SlotAlloyFurnace(EntityPlayer player, IInventory inv, int x, int y, int z) {
super(inv, x, y, z);
this.thePlayer = player;
}
public boolean isItemValid(ItemStack ist) {
return false;
}
public ItemStack decrStackSize(int num) {
if (this.getHasStack()) {
this.totalCrafted += Math.min(num, this.getStack().stackSize);
}
return super.decrStackSize(num);
}
public void onPickupFromSlot(EntityPlayer player, ItemStack ist) {
this.onCrafting(ist);
super.onPickupFromSlot(player, ist);
}
protected void onCrafting(ItemStack ist, int num) {
this.totalCrafted += num;
this.onCrafting(ist);
}
protected void onCrafting(ItemStack ist) {
ist.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.totalCrafted);
this.totalCrafted = 0;
AchieveLib.onAlloy(this.thePlayer, ist);
}
}

View File

@ -0,0 +1,133 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.core.CoreLib;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
public class SlotCraftRefill extends SlotCrafting {
private IInventory inv;
private IInventory craftingMatrix;
private ContainerAdvBench bench;
public SlotCraftRefill(EntityPlayer player, IInventory matrix, IInventory result, IInventory all, ContainerAdvBench evh, int id, int x, int y) {
super(player, matrix, result, id, x, y);
this.inv = all;
this.craftingMatrix = matrix;
this.bench = evh;
}
private int findMatch(ItemStack a) {
for(int i = 0; i < 18; ++i) {
ItemStack test = this.inv.getStackInSlot(10 + i);
if (test != null && test.stackSize != 0 && CoreLib.matchItemStackOre(a, test)) {
return 10 + i;
}
}
return -1;
}
public boolean isLastUse() {
int bits = 0;
for(int i = 0; i < 9; ++i) {
ItemStack test = this.inv.getStackInSlot(i);
if (test == null) {
bits |= 1 << i;
} else if (!test.isStackable()) {
bits |= 1 << i;
} else if (test.stackSize > 1) {
bits |= 1 << i;
}
}
if (bits == 511) {
return false;
} else {
for(int i = 0; i < 18; ++i) {
ItemStack test = this.inv.getStackInSlot(10 + i);
if (test != null && test.stackSize != 0) {
int sc = test.stackSize;
for(int j = 0; j < 9; ++j) {
if ((bits & 1 << j) <= 0) {
ItemStack st = this.inv.getStackInSlot(j);
if (st != null && CoreLib.matchItemStackOre(st, test)) {
bits |= 1 << j;
if (--sc == 0) {
break;
}
}
}
}
}
}
return bits != 511;
}
}
public void onPickupFromSlot(EntityPlayer player, ItemStack ist) {
ItemStack[] plan = this.bench.getPlanItems();
ItemStack[] cur = new ItemStack[9];
for(int i = 0; i < 9; ++i) {
ItemStack idx = this.inv.getStackInSlot(i);
if (idx == null) {
cur[i] = null;
} else {
cur[i] = idx.copy();
}
}
boolean lastUse = this.isLastUse();
if (plan != null) {
for(int i = 0; i < 9; ++i) {
if (cur[i] == null && plan[i] != null) {
int m = this.findMatch(plan[i]);
if (m >= 0) {
ItemStack ch = this.inv.getStackInSlot(m);
if (ch != null) {
this.inv.decrStackSize(m, 1);
if (ch.getItem().getContainerItem() != null) {
ItemStack s = ch.getItem().getContainerItem(ch);
this.inv.setInventorySlotContents(m, s);
}
}
}
}
}
}
super.onPickupFromSlot(player, ist);
if (!lastUse) {
for(int i = 0; i < 9; ++i) {
if (cur[i] != null) {
ItemStack nsl = this.inv.getStackInSlot(i);
if (plan == null || plan[i] == null) {
if (nsl != null) {
if (!CoreLib.matchItemStackOre(nsl, cur[i]) && cur[i].getItem().getContainerItem() != null) {
ItemStack ctr = cur[i].getItem().getContainerItem(cur[i]);
if (ctr != null && ctr.getItem() == nsl.getItem()) {
int id = this.findMatch(cur[i]);
if (id >= 0) {
this.inv.setInventorySlotContents(id, nsl);
}
}
}
} else {
int id = this.findMatch(cur[i]);
if (id >= 0) {
this.inv.setInventorySlotContents(i, this.inv.decrStackSize(id, 1));
}
}
}
}
}
}
this.bench.onCraftMatrixChanged(this.craftingMatrix);
}
}

View File

@ -0,0 +1,175 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.CoreLib;
import java.util.stream.IntStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
public class TileAdvBench extends TileAppliance implements ISidedInventory {
private ItemStack[] contents = new ItemStack[28];
@Override
public int getExtendedID() {
return 3;
}
public boolean canUpdate() {
return true;
}
@Override
public boolean onBlockActivated(EntityPlayer player) {
if (player.isSneaking()) {
return false;
} else {
if (!super.worldObj.isRemote) {
player.openGui(RedPowerBase.instance, 2, super.worldObj, super.xCoord, super.yCoord, super.zCoord);
}
return true;
}
}
@Override
public void onBlockRemoval() {
for(int i = 0; i < 27; ++i) {
ItemStack ist = this.contents[i];
if (ist != null && ist.stackSize > 0) {
CoreLib.dropItem(super.worldObj, super.xCoord, super.yCoord, super.zCoord, ist);
}
}
}
public int getSizeInventory() {
return 28;
}
public ItemStack getStackInSlot(int i) {
return this.contents[i];
}
public ItemStack decrStackSize(int i, int j) {
if (this.contents[i] == null) {
return null;
} else if (this.contents[i].stackSize <= j) {
ItemStack tr = this.contents[i];
this.contents[i] = null;
this.markDirty();
return tr;
} else {
ItemStack tr = this.contents[i].splitStack(j);
if (this.contents[i].stackSize == 0) {
this.contents[i] = null;
}
this.markDirty();
return tr;
}
}
public ItemStack getStackInSlotOnClosing(int i) {
if (this.contents[i] == null) {
return null;
} else {
ItemStack ist = this.contents[i];
this.contents[i] = null;
return ist;
}
}
public void setInventorySlotContents(int i, ItemStack ist) {
this.contents[i] = ist;
if (ist != null && ist.stackSize > this.getInventoryStackLimit()) {
ist.stackSize = this.getInventoryStackLimit();
}
this.markDirty();
}
public String getInventoryName() {
return "tile.rpabench.name";
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer player) {
TileEntity tile = super.worldObj.getTileEntity(super.xCoord, super.yCoord, super.zCoord);
return tile == this
&& tile != null
&& !tile.isInvalid()
&& player.getDistanceSq((double)super.xCoord + 0.5, (double)super.yCoord + 0.5, (double)super.zCoord + 0.5) <= 64.0;
}
public void closeInventory() {
}
public void openInventory() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
NBTTagList items = data.getTagList("Items", 10);
this.contents = new ItemStack[this.getSizeInventory()];
for(int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
int j = item.getByte("Slot") & 255;
if (j >= 0 && j < this.contents.length) {
this.contents[j] = ItemStack.loadItemStackFromNBT(item);
}
}
this.markDirty();
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
NBTTagList items = new NBTTagList();
for(int i = 0; i < this.contents.length; ++i) {
if (this.contents[i] != null) {
NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte)i);
this.contents[i].writeToNBT(item);
items.appendTag(item);
}
}
data.setTag("Items", items);
}
public int[] getAccessibleSlotsFromSide(int side) {
switch(side) {
case 1:
return IntStream.range(0, 9).toArray();
default:
return side != (super.Rotation ^ 1) ? IntStream.range(10, 28).toArray() : new int[0];
}
}
public boolean canInsertItem(int slotID, ItemStack itemStack, int side) {
return side != (super.Rotation ^ 1) && slotID >= 0 && slotID < 28 && slotID != 9;
}
public boolean canExtractItem(int slotID, ItemStack itemStack, int side) {
return side == 0 && slotID >= 10 && slotID < 28;
}
public boolean hasCustomInventoryName() {
return false;
}
public boolean isItemValidForSlot(int slotID, ItemStack stack) {
return slotID != 9 || stack.getItem() == RedPowerBase.itemPlanBlank || stack.getItem() == RedPowerBase.itemPlanFull;
}
}

View File

@ -0,0 +1,285 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.CraftLib;
import java.util.stream.IntStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.EnumSkyBlock;
public class TileAlloyFurnace extends TileAppliance implements IInventory, ISidedInventory {
private ItemStack[] contents = new ItemStack[11];
int totalburn = 0;
int burntime = 0;
int cooktime = 0;
private void updateLight() {
super.worldObj.updateLightByType(EnumSkyBlock.Block, super.xCoord, super.yCoord, super.zCoord);
}
@Override
public int getExtendedID() {
return 0;
}
@Override
public void updateEntity() {
super.updateEntity();
boolean btu = false;
if (this.burntime > 0) {
--this.burntime;
if (this.burntime == 0) {
btu = true;
super.Active = false;
}
}
if (!super.worldObj.isRemote) {
boolean cs = this.canSmelt();
if (this.burntime == 0 && cs && this.contents[9] != null) {
this.burntime = this.totalburn = CoreLib.getBurnTime(this.contents[9]);
if (this.burntime > 0) {
super.Active = true;
if (this.contents[9].getItem().getContainerItem() != null) {
this.contents[9] = new ItemStack(this.contents[9].getItem().getContainerItem());
} else {
--this.contents[9].stackSize;
}
if (this.contents[9].stackSize == 0) {
this.contents[9] = null;
}
if (!btu) {
this.updateBlock();
this.updateLight();
}
}
}
if (this.burntime > 0 && cs) {
++this.cooktime;
if (this.cooktime == 200) {
this.cooktime = 0;
this.smeltItem();
this.markDirty();
}
} else {
this.cooktime = 0;
}
if (btu) {
this.updateBlock();
this.updateLight();
}
}
}
private boolean canSmelt() {
ItemStack ist = CraftLib.getAlloyResult(this.contents, 0, 9, false);
if (ist == null) {
return false;
} else if (this.contents[10] == null) {
return true;
} else if (!this.contents[10].isItemEqual(ist)) {
return false;
} else {
int st = this.contents[10].stackSize + ist.stackSize;
return st <= this.getInventoryStackLimit() && st <= ist.getMaxStackSize();
}
}
private void smeltItem() {
if (this.canSmelt()) {
ItemStack ist = CraftLib.getAlloyResult(this.contents, 0, 9, true);
if (this.contents[10] == null) {
this.contents[10] = ist.copy();
} else {
this.contents[10].stackSize += ist.stackSize;
}
}
}
int getCookScaled(int i) {
return this.cooktime * i / 200;
}
int getBurnScaled(int i) {
return this.totalburn == 0 ? 0 : this.burntime * i / this.totalburn;
}
@Override
public boolean onBlockActivated(EntityPlayer player) {
if (player.isSneaking()) {
return false;
} else {
if (!super.worldObj.isRemote) {
player.openGui(RedPowerBase.instance, 1, super.worldObj, super.xCoord, super.yCoord, super.zCoord);
}
return true;
}
}
@Override
public void onBlockRemoval() {
for(int i = 0; i < 11; ++i) {
ItemStack ist = this.contents[i];
if (ist != null && ist.stackSize > 0) {
CoreLib.dropItem(super.worldObj, super.xCoord, super.yCoord, super.zCoord, ist);
}
}
}
public int getSizeInventory() {
return 11;
}
public ItemStack getStackInSlot(int slotId) {
return this.contents[slotId];
}
public ItemStack decrStackSize(int slotId, int amount) {
if (this.contents[slotId] == null) {
return null;
} else if (this.contents[slotId].stackSize <= amount) {
ItemStack tr = this.contents[slotId];
this.contents[slotId] = null;
this.markDirty();
return tr;
} else {
ItemStack tr = this.contents[slotId].splitStack(amount);
if (this.contents[slotId].stackSize == 0) {
this.contents[slotId] = null;
}
this.markDirty();
return tr;
}
}
public ItemStack getStackInSlotOnClosing(int slotId) {
if (this.contents[slotId] == null) {
return null;
} else {
ItemStack ist = this.contents[slotId];
this.contents[slotId] = null;
return ist;
}
}
public void setInventorySlotContents(int slotId, ItemStack ist) {
this.contents[slotId] = ist;
if (ist != null && ist.stackSize > this.getInventoryStackLimit()) {
ist.stackSize = this.getInventoryStackLimit();
}
this.markDirty();
}
public String getInventoryName() {
return "tile.rpafurnace.name";
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer player) {
return !this.isInvalid()
&& super.worldObj.getTileEntity(super.xCoord, super.yCoord, super.zCoord) == this
&& player.getDistanceSq((double)super.xCoord + 0.5, (double)super.yCoord + 0.5, (double)super.zCoord + 0.5) <= 64.0;
}
public void closeInventory() {
}
public void openInventory() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
NBTTagList items = data.getTagList("Items", 10);
this.contents = new ItemStack[this.getSizeInventory()];
for(int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
int j = item.getByte("Slot") & 255;
if (j >= 0 && j < this.contents.length) {
this.contents[j] = ItemStack.loadItemStackFromNBT(item);
}
}
this.totalburn = data.getShort("TotalBurn");
this.burntime = data.getShort("BurnTime");
this.cooktime = data.getShort("CookTime");
super.readFromNBT(data);
}
@Override
public void writeToNBT(NBTTagCompound data) {
NBTTagList items = new NBTTagList();
for(int i = 0; i < this.contents.length; ++i) {
if (this.contents[i] != null) {
NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte)i);
this.contents[i].writeToNBT(item);
items.appendTag(item);
}
}
data.setTag("Items", items);
data.setShort("TotalBurn", (short)this.totalburn);
data.setShort("BurnTime", (short)this.burntime);
data.setShort("CookTime", (short)this.cooktime);
super.writeToNBT(data);
}
public int[] getAccessibleSlotsFromSide(int side) {
switch(side) {
case 0:
return new int[]{10};
case 1:
return IntStream.range(0, 9).toArray();
default:
return side != (super.Rotation ^ 1) ? new int[]{9} : new int[0];
}
}
public boolean canInsertItem(int slotID, ItemStack stack, int side) {
switch(side) {
case 1:
return slotID >= 0 && slotID < 9;
default:
return side != (super.Rotation ^ 1) ? TileEntityFurnace.isItemFuel(stack) : false;
}
}
public boolean canExtractItem(int slotID, ItemStack stack, int side) {
return slotID == 10 && side == 0;
}
public boolean hasCustomInventoryName() {
return false;
}
public boolean isItemValidForSlot(int slotID, ItemStack stack) {
return TileEntityFurnace.isItemFuel(stack) && slotID == 9 || slotID >= 0 && slotID < 9;
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
super.readFromPacket(tag);
this.updateLight();
}
}

View File

@ -0,0 +1,83 @@
package com.eloraam.redpower.base;
import com.eloraam.redpower.RedPowerBase;
import com.eloraam.redpower.core.IFrameSupport;
import com.eloraam.redpower.core.TileExtended;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
public class TileAppliance extends TileExtended implements IFrameSupport {
public int Rotation = 0;
public boolean Active = false;
@Override
public void onBlockPlaced(ItemStack ist, int side, EntityLivingBase ent) {
this.Rotation = (int)Math.floor((double)(ent.rotationYaw * 4.0F / 360.0F) + 0.5) & 3;
if (ent instanceof EntityPlayer) {
super.Owner = ((EntityPlayer)ent).getGameProfile();
}
}
public Block getBlockType() {
return RedPowerBase.blockAppliance;
}
public int getLightValue() {
return this.Active ? 13 : 0;
}
@Override
public void writeFramePacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
tag.setByte("ps", (byte)(this.Active ? 1 : 0));
}
@Override
public void readFramePacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
this.Active = tag.getByte("ps") > 0;
}
@Override
public void onFrameRefresh(IBlockAccess iba) {
}
@Override
public void onFramePickup(IBlockAccess iba) {
}
@Override
public void onFrameDrop() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.Rotation = data.getByte("rot");
this.Active = data.getByte("ps") > 0;
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByte("ps", (byte)(this.Active ? 1 : 0));
data.setByte("rot", (byte)this.Rotation);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
this.Active = tag.getByte("ps") > 0;
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
tag.setByte("ps", (byte)(this.Active ? 1 : 0));
}
}

View File

@ -0,0 +1,32 @@
package com.eloraam.redpower.compat;
import com.eloraam.redpower.core.BlockMultipart;
import com.eloraam.redpower.core.CreativeExtraTabs;
import net.minecraft.block.material.Material;
public class BlockMachineCompat extends BlockMultipart {
public BlockMachineCompat() {
super(Material.rock);
this.setHardness(2.0F);
this.setCreativeTab(CreativeExtraTabs.tabMachine);
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean isNormalCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(int meta) {
return meta;
}
}

View File

@ -0,0 +1,72 @@
package com.eloraam.redpower.compat;
import com.eloraam.redpower.core.BlockExtended;
import com.eloraam.redpower.core.ItemExtended;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemMachineCompat extends ItemExtended {
public ItemMachineCompat(Block block) {
super(block);
}
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xp, float yp, float zp) {
Block bid = world.getBlock(x, y, z);
Block bl = Block.getBlockFromItem(this);
if (bid == Blocks.snow) {
side = 1;
} else if (bid != Blocks.vine && bid != Blocks.tallgrass && bid != Blocks.deadbush) {
switch(side) {
case 0:
--y;
break;
case 1:
++y;
break;
case 2:
--z;
break;
case 3:
++z;
break;
case 4:
--x;
break;
default:
++x;
}
}
if (stack.stackSize == 0) {
return false;
} else if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
} else if (y >= world.getHeight() - 1) {
return false;
} else if (!world.canPlaceEntityOnSide(bl, x, y, z, false, side, player, stack)) {
return false;
} else {
if (world.setBlock(x, y, z, bl, this.getMetadata(stack.getItemDamage()), 3)) {
if (world.getBlock(x, y, z) == bl) {
BlockExtended bex = (BlockExtended)bl;
bex.onBlockPlacedBy(world, x, y, z, side, player, stack);
}
world.playSoundEffect(
(double)((float)x + 0.5F),
(double)((float)y + 0.5F),
(double)((float)z + 0.5F),
bl.stepSound.func_150496_b(),
(bl.stepSound.getVolume() + 1.0F) / 2.0F,
bl.stepSound.getPitch() * 0.8F
);
--stack.stackSize;
}
return true;
}
}
}

View File

@ -0,0 +1,92 @@
package com.eloraam.redpower.compat;
import com.eloraam.redpower.core.Matrix3;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import com.eloraam.redpower.core.RenderModel;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
public class RenderBlueEngine extends RenderCustomBlock {
private static ResourceLocation res = new ResourceLocation("rpcompat", "models/compat1.png");
protected RenderModel modelBase = RenderModel.loadModel("rpcompat:models/btengine1.obj").scale(0.0625);
protected RenderModel modelSlide = RenderModel.loadModel("rpcompat:models/btengine2.obj").scale(0.0625);
protected RenderModel modelGear = RenderModel.loadModel("rpcompat:models/btengine3.obj").scale(0.0625);
protected RenderContext context = new RenderContext();
public RenderBlueEngine(Block bl) {
super(bl);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileBlueEngine tb = (TileBlueEngine)tile;
if (tb != null) {
Tessellator tess = Tessellator.instance;
this.context.setDefaults();
this.context.setPos(x, y, z);
this.context.setOrientation(tb.Rotation, 0);
this.context.readGlobalLights(tb.getWorldObj(), tb.xCoord, tb.yCoord, tb.zCoord);
this.context.setBrightness(super.getMixedBrightness(tb));
this.context.bindTexture(res);
this.context.bindModelOffset(this.modelBase, 0.5, 0.5, 0.5);
tess.startDrawingQuads();
this.context.renderModelGroup(0, 0);
this.context.renderModelGroup(1, tb.Charged ? (tb.Active ? 3 : 2) : 1);
tess.draw();
int lv = tb.getWorldObj().getLightBrightnessForSkyBlocks(tb.xCoord, tb.yCoord, tb.zCoord, 0);
tess.startDrawingQuads();
tess.setBrightness(lv);
if (tb.Active) {
partialTicks += (float)tb.PumpTick;
if (tb.PumpSpeed > 0) {
partialTicks /= (float)tb.PumpSpeed;
}
} else {
partialTicks = 0.0F;
}
this.context.useNormal = true;
this.context.setPos(x, y, z);
this.context.setOrientation(tb.Rotation, 0);
this.context.setRelPos(0.0, 0.1875 * (0.5 - 0.5 * Math.cos(Math.PI * (double)partialTicks)), 0.0);
this.context.bindModelOffset(this.modelSlide, 0.5, 0.5, 0.5);
this.context.renderModelGroup(0, 0);
this.context.basis = Matrix3.getRotY(Math.PI / 2 * (double)partialTicks).multiply(this.context.basis);
this.context.setRelPos(0.5, 0.34375, 0.5);
this.context.bindModelOffset(this.modelGear, 0.5, 0.5, 0.5);
this.context.renderModelGroup(0, 0);
tess.draw();
}
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.bindTexture(res);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
this.context.useNormal = true;
this.context.bindModelOffset(this.modelBase, 0.5, 0.5, 0.5);
this.context.renderModelGroup(0, 0);
this.context.renderModelGroup(1, 1);
this.context.bindModelOffset(this.modelSlide, 0.5, 0.5, 0.5);
this.context.renderModelGroup(0, 0);
this.context.setPos(0.0, -0.15625, 0.0);
this.context.bindModel(this.modelGear);
this.context.renderModelGroup(0, 0);
this.context.useNormal = false;
tess.draw();
}
}

View File

@ -0,0 +1,193 @@
package com.eloraam.redpower.compat;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyReceiver;
import com.eloraam.redpower.core.BluePowerConductor;
import com.eloraam.redpower.core.BluePowerEndpoint;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.IBluePowerConnectable;
import com.eloraam.redpower.core.RedPowerLib;
import com.eloraam.redpower.core.WorldCoord;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileBlueEngine extends TileMachineCompat implements IBluePowerConnectable, IEnergyConnection {
private BluePowerEndpoint cond = new BluePowerEndpoint() {
@Override
public TileEntity getParent() {
return TileBlueEngine.this;
}
};
public int ConMask = -1;
public byte PumpTick = 0;
public byte PumpSpeed = 16;
private int Flywheel = 0;
@Override
public int getConnectableMask() {
int wm = RedPowerLib.getConDirMask(super.Rotation ^ 1) | 15 << ((super.Rotation ^ 1) << 2);
return 16777215 & ~wm | 16777216 << super.Rotation;
}
@Override
public int getConnectClass(int side) {
return 65;
}
@Override
public int getCornerPowerMode() {
return 0;
}
@Override
public BluePowerConductor getBlueConductor(int side) {
return this.cond;
}
@Override
public void onBlockNeighborChange(Block bl) {
this.ConMask = -1;
int cm = this.getConnectableMask();
if (RedPowerLib.isPowered(super.worldObj, super.xCoord, super.yCoord, super.zCoord, cm, cm >> 24)) {
if (!super.Powered) {
super.Powered = true;
this.updateBlock();
}
} else {
super.Powered = false;
this.updateBlock();
}
}
protected void deliverPower() {
WorldCoord pos = new WorldCoord(this);
pos.step(super.Rotation ^ 1);
IEnergyReceiver ipr = CoreLib.getTileEntity(super.worldObj, pos, IEnergyReceiver.class);
ForgeDirection oppSide = ForgeDirection.getOrientation(super.Rotation);
if (ipr != null && ipr.canConnectEnergy(oppSide)) {
this.Flywheel -= ipr.receiveEnergy(oppSide, this.Flywheel * 10, false) / 10;
}
}
@Override
public void onTileTick() {
}
@Override
public void updateEntity() {
super.updateEntity();
if (!super.worldObj.isRemote) {
if (this.ConMask < 0) {
this.ConMask = RedPowerLib.getConnections(super.worldObj, this, super.xCoord, super.yCoord, super.zCoord);
this.cond.recache(this.ConMask, 0);
}
this.cond.iterate();
this.markDirty();
boolean act = super.Active;
if (super.Active) {
++this.PumpTick;
int sp = this.PumpTick;
if (sp == this.PumpSpeed) {
this.deliverPower();
}
if (sp >= this.PumpSpeed * 2) {
this.PumpTick = 0;
if (this.PumpSpeed > 4) {
--this.PumpSpeed;
}
super.Active = false;
}
if (super.Powered && this.Flywheel < 512) {
double draw = Math.min((double)Math.min(512 - this.Flywheel, 32), 0.002 * this.cond.getEnergy(60.0));
this.cond.drawPower(1000.0 * draw);
this.Flywheel = (int)((double)this.Flywheel + draw);
}
this.cond.drawPower(50.0);
}
if (this.cond.getVoltage() < 60.0) {
if (super.Charged && this.cond.Flow == 0) {
super.Charged = false;
this.updateBlock();
}
} else {
if (!super.Charged) {
super.Charged = true;
this.updateBlock();
}
if (super.Charged && super.Powered) {
super.Active = true;
}
if (super.Active != act) {
if (super.Active) {
this.PumpSpeed = 16;
}
this.updateBlock();
}
}
} else if (super.Active) {
++this.PumpTick;
if (this.PumpTick >= this.PumpSpeed * 2) {
this.PumpTick = 0;
if (this.PumpSpeed > 4) {
--this.PumpSpeed;
}
}
} else {
this.PumpTick = 0;
}
}
@Override
public int getExtendedID() {
return 0;
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
this.cond.readFromNBT(tag);
this.PumpTick = tag.getByte("ptk");
this.PumpSpeed = tag.getByte("spd");
this.Flywheel = tag.getInteger("flyw");
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
this.cond.writeToNBT(tag);
tag.setByte("ptk", this.PumpTick);
tag.setByte("spd", this.PumpSpeed);
tag.setInteger("flyw", this.Flywheel);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
super.readFromPacket(tag);
this.PumpSpeed = tag.getByte("spd");
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
super.writeToPacket(tag);
tag.setByte("spd", this.PumpSpeed);
}
@Override
public boolean canConnectEnergy(ForgeDirection side) {
return side.getOpposite() == ForgeDirection.getOrientation(super.Rotation);
}
}

View File

@ -0,0 +1,177 @@
package com.eloraam.redpower.compat;
import com.eloraam.redpower.RedPowerCompat;
import com.eloraam.redpower.core.BlockExtended;
import com.eloraam.redpower.core.BlockMultipart;
import com.eloraam.redpower.core.IFrameSupport;
import com.eloraam.redpower.core.IRotatable;
import com.eloraam.redpower.core.TileMultipart;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
public class TileMachineCompat extends TileMultipart implements IRotatable, IFrameSupport {
public int Rotation = 0;
public boolean Active = false;
public boolean Powered = false;
public boolean Delay = false;
public boolean Charged = false;
public int getFacing(EntityLivingBase ent) {
int yawrx = (int)Math.floor((double)(ent.rotationYaw * 4.0F / 360.0F) + 0.5) & 3;
if (Math.abs(ent.posX - (double)super.xCoord) < 2.0 && Math.abs(ent.posZ - (double)super.zCoord) < 2.0) {
double p = ent.posY + 1.82 - (double)ent.yOffset - (double)super.yCoord;
if (p > 2.0) {
return 0;
}
if (p < 0.0) {
return 1;
}
}
switch(yawrx) {
case 0:
return 3;
case 1:
return 4;
case 2:
return 2;
default:
return 5;
}
}
@Override
public void onBlockPlaced(ItemStack ist, int side, EntityLivingBase ent) {
this.Rotation = this.getFacing(ent);
}
public Block getBlockType() {
return RedPowerCompat.blockMachineCompat;
}
@Override
public void addHarvestContents(List<ItemStack> items) {
items.add(new ItemStack(this.getBlockType(), 1, this.getExtendedID()));
}
@Override
public void onHarvestPart(EntityPlayer player, int part, boolean willHarvest) {
this.breakBlock(willHarvest);
}
@Override
public float getPartStrength(EntityPlayer player, int part) {
BlockExtended bl = RedPowerCompat.blockMachineCompat;
return player.getBreakSpeed(bl, false, super.blockMetadata, super.xCoord, super.yCoord, super.zCoord) / (bl.getHardness() * 30.0F);
}
@Override
public boolean blockEmpty() {
return false;
}
@Override
public void setPartBounds(BlockMultipart bl, int part) {
bl.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public int getSolidPartsMask() {
return 1;
}
@Override
public int getPartsMask() {
return 1;
}
@Override
public int getPartMaxRotation(int part, boolean sec) {
return sec ? 0 : 5;
}
@Override
public int getPartRotation(int part, boolean sec) {
return sec ? 0 : this.Rotation;
}
@Override
public void setPartRotation(int part, boolean sec, int rot) {
if (!sec) {
this.Rotation = rot;
this.updateBlockChange();
}
}
@Override
public void writeFramePacket(NBTTagCompound tag) {
int ps = (this.Active ? 1 : 0) | (this.Powered ? 2 : 0) | (this.Delay ? 4 : 0) | (this.Charged ? 8 : 0);
tag.setByte("ps", (byte)ps);
tag.setByte("rot", (byte)this.Rotation);
}
@Override
public void readFramePacket(NBTTagCompound tag) {
int ps = tag.getByte("ps");
this.Rotation = tag.getByte("rot");
this.Active = (ps & 1) > 0;
this.Powered = (ps & 2) > 0;
this.Delay = (ps & 4) > 0;
this.Charged = (ps & 8) > 0;
}
@Override
public void onFrameRefresh(IBlockAccess iba) {
}
@Override
public void onFramePickup(IBlockAccess iba) {
}
@Override
public void onFrameDrop() {
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
int ps = tag.getByte("ps");
this.Rotation = tag.getByte("rot");
this.Active = (ps & 1) > 0;
this.Powered = (ps & 2) > 0;
this.Delay = (ps & 4) > 0;
this.Charged = (ps & 8) > 0;
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
int ps = (this.Active ? 1 : 0) | (this.Powered ? 2 : 0) | (this.Delay ? 4 : 0) | (this.Charged ? 8 : 0);
tag.setByte("ps", (byte)ps);
tag.setByte("rot", (byte)this.Rotation);
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
int ps = (this.Active ? 1 : 0) | (this.Powered ? 2 : 0) | (this.Delay ? 4 : 0) | (this.Charged ? 8 : 0);
tag.setByte("ps", (byte)ps);
tag.setByte("rot", (byte)this.Rotation);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
int ps = tag.getByte("ps");
this.Rotation = tag.getByte("rot");
this.Active = (ps & 1) > 0;
this.Powered = (ps & 2) > 0;
this.Delay = (ps & 4) > 0;
this.Charged = (ps & 8) > 0;
}
}

View File

@ -0,0 +1,42 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.core.BlockExtended;
import com.eloraam.redpower.core.CreativeExtraTabs;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockPeripheral extends BlockExtended {
public BlockPeripheral() {
super(Material.rock);
this.setHardness(2.0F);
this.setCreativeTab(CreativeExtraTabs.tabMachine);
}
@Override
public boolean isOpaqueCube() {
return true;
}
public boolean isNormalCube() {
return true;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
public boolean isBlockNormalCube() {
return false;
}
public boolean isSideSolid(IBlockAccess world, int i, int j, int k, ForgeDirection side) {
return true;
}
@Override
public int damageDropped(int i) {
return i;
}
}

View File

@ -0,0 +1,106 @@
package com.eloraam.redpower.control;
import java.util.List;
import com.eloraam.redpower.core.IHandleGuiEvent;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class ContainerCPU extends Container implements IHandleGuiEvent {
private TileCPU tileCPU;
private int byte0 = 0;
private int byte1 = 0;
private int rbaddr = 0;
private boolean isrun = false;
public ContainerCPU(IInventory inv, TileCPU cpu) {
this.tileCPU = cpu;
}
public ItemStack slotClick(int a, int b, int c, EntityPlayer player) {
return !this.canInteractWith(player) ? null : super.slotClick(a, b, c, player);
}
public boolean canInteractWith(EntityPlayer player) {
return this.tileCPU.isUseableByPlayer(player);
}
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
return null;
}
public void detectAndSendChanges() {
super.detectAndSendChanges();
for(ICrafting ic : (List<ICrafting>)super.crafters) {
if (this.tileCPU.diskAddr != this.byte0) {
ic.sendProgressBarUpdate(this, 0, this.tileCPU.diskAddr);
}
if (this.tileCPU.displayAddr != this.byte1) {
ic.sendProgressBarUpdate(this, 1, this.tileCPU.displayAddr);
}
if (this.tileCPU.rbaddr != this.rbaddr) {
ic.sendProgressBarUpdate(this, 2, this.tileCPU.rbaddr);
}
if (this.tileCPU.isRunning() != this.isrun) {
ic.sendProgressBarUpdate(this, 3, this.tileCPU.isRunning() ? 1 : 0);
}
}
this.byte0 = this.tileCPU.diskAddr;
this.byte1 = this.tileCPU.displayAddr;
this.rbaddr = this.tileCPU.rbaddr;
this.isrun = this.tileCPU.isRunning();
}
public void updateProgressBar(int id, int value) {
switch(id) {
case 0:
this.tileCPU.diskAddr = value;
break;
case 1:
this.tileCPU.displayAddr = value;
break;
case 2:
this.tileCPU.rbaddr = value;
break;
case 3:
this.tileCPU.sliceCycles = value > 0 ? 0 : -1;
}
}
@Override
public void handleGuiEvent(PacketGuiEvent.GuiMessageEvent message) {
try {
switch(message.eventId) {
case 1:
this.tileCPU.diskAddr = message.parameters[0];
break;
case 2:
this.tileCPU.displayAddr = message.parameters[0];
break;
case 3:
this.tileCPU.rbaddr = message.parameters[0];
break;
case 4:
this.tileCPU.warmBootCPU();
break;
case 5:
this.tileCPU.haltCPU();
break;
case 6:
this.tileCPU.coldBootCPU();
}
} catch (Throwable var3) {
}
}
}

View File

@ -0,0 +1,246 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerCore;
import com.eloraam.redpower.core.IHandleGuiEvent;
import com.eloraam.redpower.core.PacketGuiEvent;
import java.io.ByteArrayOutputStream;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class ContainerDisplay extends Container implements IHandleGuiEvent {
private TileDisplay tileDisplay;
private byte[] screen = new byte[4000];
private int cursx = 0;
private int cursy = 0;
private int cursmode = 0;
private void decompress(byte[] compress, byte[] out) {
int opos = 0;
int i = 0;
while(i < compress.length) {
if (opos >= out.length) {
return;
}
int cmd = compress[i++] & 255;
if ((cmd & 128) == 0) {
opos += cmd & 127;
} else if (cmd != 255) {
int ln = Math.min(Math.min(cmd & 127, out.length - opos), compress.length - i);
System.arraycopy(compress, i, out, opos, ln);
opos += ln;
i += ln;
} else {
if (i + 2 > compress.length) {
return;
}
int ln = Math.min(compress[i] & 255, out.length - opos);
for(int j = 0; j < ln; ++j) {
out[opos + j] = compress[i + 1];
}
opos += ln;
i += 2;
}
}
}
public ContainerDisplay(IInventory inv, TileDisplay td) {
this.tileDisplay = td;
}
public ItemStack slotClick(int a, int b, int c, EntityPlayer player) {
return !this.canInteractWith(player) ? null : super.slotClick(a, b, c, player);
}
public boolean canInteractWith(EntityPlayer player) {
return this.tileDisplay.isUseableByPlayer(player);
}
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
return null;
}
private byte[] getDisplayRLE() {
ContainerDisplay.RLECompressor rle = new ContainerDisplay.RLECompressor();
for(int i = 0; i < 4000; ++i) {
rle.addByte(this.tileDisplay.screen[i], this.screen[i] != this.tileDisplay.screen[i]);
this.screen[i] = this.tileDisplay.screen[i];
}
rle.flush();
return rle.getByteArray();
}
public void detectAndSendChanges() {
super.detectAndSendChanges();
byte[] drl = this.getDisplayRLE();
for(ICrafting ic : (List<ICrafting>)super.crafters) {
if (this.tileDisplay.cursX != this.cursx) {
ic.sendProgressBarUpdate(this, 0, this.tileDisplay.cursX);
}
if (this.tileDisplay.cursY != this.cursy) {
ic.sendProgressBarUpdate(this, 1, this.tileDisplay.cursY);
}
if (this.tileDisplay.cursMode != this.cursmode) {
ic.sendProgressBarUpdate(this, 2, this.tileDisplay.cursMode);
}
if (drl != null) {
RedPowerCore.sendPacketToCrafting(ic, new PacketGuiEvent.GuiMessageEvent(2, super.windowId, drl));
}
}
this.cursx = this.tileDisplay.cursX;
this.cursy = this.tileDisplay.cursY;
this.cursmode = this.tileDisplay.cursMode;
}
public void updateProgressBar(int id, int value) {
switch(id) {
case 0:
this.tileDisplay.cursX = value;
return;
case 1:
this.tileDisplay.cursY = value;
return;
case 2:
this.tileDisplay.cursMode = value;
}
}
@Override
public void handleGuiEvent(PacketGuiEvent.GuiMessageEvent message) {
try {
switch(message.eventId) {
case 1:
this.tileDisplay.pushKey(message.parameters[0]);
this.tileDisplay.updateBlock();
break;
case 2:
this.decompress(message.parameters, this.tileDisplay.screen);
}
} catch (Throwable var3) {
}
}
public class RLECompressor {
ByteArrayOutputStream bas = new ByteArrayOutputStream();
byte[] datbuf = new byte[256];
byte srledat = 0;
int rleoffs = 0;
int srleoffs = 0;
int datpos = 0;
boolean changed = false;
public void writeRLE() {
this.bas.write((byte)this.rleoffs);
this.datpos = 0;
this.rleoffs = 0;
this.srleoffs = 0;
}
public void writeSRLE() {
this.bas.write(-1);
this.bas.write((byte)this.srleoffs);
this.bas.write(this.srledat);
this.datpos = 0;
this.rleoffs = 0;
this.srleoffs = 0;
}
public void writeDat(int bytes) {
if (bytes != 0) {
this.bas.write((byte)(128 | bytes));
this.bas.write(this.datbuf, 0, bytes);
this.datpos -= bytes;
}
}
public void addByte(byte b, boolean diff) {
if (diff) {
this.changed = true;
if (this.rleoffs > 5 && this.rleoffs >= this.srleoffs) {
this.writeDat(this.datpos - this.rleoffs);
this.writeRLE();
}
this.rleoffs = 0;
} else {
++this.rleoffs;
if (this.rleoffs >= 127) {
++this.datpos;
this.writeDat(this.datpos - this.rleoffs);
this.writeRLE();
return;
}
}
if (this.srleoffs == 0) {
this.srledat = b;
this.srleoffs = 1;
} else if (b == this.srledat) {
++this.srleoffs;
if (this.srleoffs >= 127) {
++this.datpos;
this.writeDat(this.datpos - this.srleoffs);
this.writeSRLE();
return;
}
} else {
if (this.srleoffs > 5 && this.srleoffs >= this.rleoffs) {
this.writeDat(this.datpos - this.srleoffs);
this.writeSRLE();
}
this.srledat = b;
this.srleoffs = 1;
}
this.datbuf[this.datpos] = b;
++this.datpos;
int rem = Math.max(this.srleoffs, this.rleoffs);
if (rem <= 5 && this.datpos >= 126) {
this.writeDat(this.datpos);
this.srleoffs = 0;
this.rleoffs = 0;
} else if (this.datpos - rem >= 126) {
this.writeDat(this.datpos - rem);
}
}
public void flush() {
this.datpos -= this.rleoffs;
this.srleoffs = Math.max(0, this.srleoffs - this.rleoffs);
if (this.datpos != 0) {
if (this.srleoffs > 5) {
this.writeDat(this.datpos - this.srleoffs);
this.writeSRLE();
} else {
this.writeDat(this.datpos);
}
}
}
byte[] getByteArray() {
return !this.changed ? null : this.bas.toByteArray();
}
}
}

View File

@ -0,0 +1,151 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerCore;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiCPU extends GuiContainer {
private static final ResourceLocation res = new ResourceLocation("rpcontrol", "textures/gui/cpugui.png");
private TileCPU tileCPU;
public GuiCPU(InventoryPlayer pli, TileCPU cpu) {
super(new ContainerCPU(pli, cpu));
this.tileCPU = cpu;
super.ySize = 145;
super.xSize = 227;
}
public GuiCPU(Container cn) {
super(cn);
super.ySize = 145;
super.xSize = 227;
}
protected void drawGuiContainerForegroundLayer(int p1, int p2) {
}
protected void drawGuiContainerBackgroundLayer(float f, int p1, int p2) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(res);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
int bits = this.tileCPU.diskAddr;
for(int n = 0; n < 8; ++n) {
if ((bits & 1 << n) != 0) {
this.drawTexturedModalRect(j + 14 + n * 12, k + 57, 227 + (n >> 2) * 12, 0, 12, 32);
}
}
bits = this.tileCPU.displayAddr;
for(int n = 0; n < 8; ++n) {
if ((bits & 1 << n) != 0) {
this.drawTexturedModalRect(j + 118 + n * 12, k + 57, 227 + (n >> 2) * 12, 0, 12, 32);
}
}
bits = this.tileCPU.rbaddr;
for(int n = 0; n < 8; ++n) {
if ((bits & 1 << n) != 0) {
this.drawTexturedModalRect(j + 118 + n * 12, k + 101, 227 + (n >> 2) * 12, 0, 12, 32);
}
}
if (this.tileCPU.isRunning()) {
this.drawTexturedModalRect(j + 102, k + 99, 227, 32, 8, 8);
} else {
this.drawTexturedModalRect(j + 102, k + 112, 227, 32, 8, 8);
}
super.fontRendererObj.drawString(I18n.format("gui.cpu.diskid", new Object[]{this.tileCPU.diskAddr & 0xFF}), j + 14, k + 47, -1);
super.fontRendererObj.drawString(I18n.format("gui.cpu.consoleid", new Object[]{this.tileCPU.displayAddr & 0xFF}), j + 118, k + 47, -1);
super.fontRendererObj.drawString(I18n.format("gui.cpu.selfid", new Object[]{this.tileCPU.rbaddr & 0xFF}), j + 118, k + 91, -1);
super.fontRendererObj.drawString(I18n.format("gui.cpu.start", new Object[0]), j + 50, k + 99, -1);
super.fontRendererObj.drawString(I18n.format("gui.cpu.halt", new Object[0]), j + 50, k + 112, -1);
super.fontRendererObj.drawString(I18n.format("gui.cpu.reset", new Object[0]), j + 50, k + 125, -1);
}
private void sendSimple(int n, byte m) {
if (super.mc.theWorld.isRemote) {
RedPowerCore.sendPacketToServer(new PacketGuiEvent.GuiMessageEvent(n, super.inventorySlots.windowId, m));
}
}
private boolean sendEvent(int n) {
if (super.mc.theWorld.isRemote) {
RedPowerCore.sendPacketToServer(new PacketGuiEvent.GuiMessageEvent(n, super.inventorySlots.windowId, (byte)0));
return false;
} else {
return true;
}
}
protected void mouseClicked(int mouseX, int mouseY, int button) {
int x = mouseX - (super.width - super.xSize) / 2;
int y = mouseY - (super.height - super.ySize) / 2;
if (y >= 57 && y <= 89) {
for(int n = 0; n < 8; ++n) {
if (x >= 14 + n * 12 && x <= 26 + n * 12) {
this.tileCPU.diskAddr ^= 1 << n;
this.sendSimple(1, (byte)this.tileCPU.diskAddr);
return;
}
}
for(int n = 0; n < 8; ++n) {
if (x >= 118 + n * 12 && x <= 130 + n * 12) {
this.tileCPU.displayAddr ^= 1 << n;
this.sendSimple(2, (byte)this.tileCPU.displayAddr);
return;
}
}
}
if (y >= 101 && y <= 133) {
for(int n = 0; n < 8; ++n) {
if (x >= 118 + n * 12 && x <= 130 + n * 12) {
this.tileCPU.rbaddr ^= 1 << n;
this.sendSimple(3, (byte)this.tileCPU.rbaddr);
return;
}
}
}
if (x >= 87 && x <= 96) {
if (y >= 98 && y <= 107) {
if (this.sendEvent(4)) {
this.tileCPU.warmBootCPU();
}
return;
}
if (y >= 111 && y <= 120) {
if (this.sendEvent(5)) {
this.tileCPU.haltCPU();
}
return;
}
if (y >= 124 && y <= 133) {
if (this.sendEvent(6)) {
this.tileCPU.coldBootCPU();
}
return;
}
}
super.mouseClicked(mouseX, mouseY, button);
}
}

View File

@ -0,0 +1,124 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerCore;
import com.eloraam.redpower.core.PacketGuiEvent;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiDisplay extends GuiContainer {
private static ResourceLocation screenTextures = new ResourceLocation("rpcontrol", "textures/gui/displaygui.png");
private TileDisplay disp;
public GuiDisplay(IInventory inv, TileDisplay td) {
super(new ContainerDisplay(inv, td));
super.xSize = 350;
super.ySize = 230;
this.disp = td;
}
private void sendKey(int id) {
RedPowerCore.sendPacketToServer(new PacketGuiEvent.GuiMessageEvent(1, super.inventorySlots.windowId, (byte)id));
}
protected void keyTyped(char symbol, int key) {
if (key == 1) {
super.mc.thePlayer.closeScreen();
} else {
if (symbol == '\n') {
symbol = '\r';
}
byte id = 0;
if (isShiftKeyDown()) {
id = (byte)(id | 64);
}
if (isCtrlKeyDown()) {
id = (byte)(id | 32);
}
switch(key) {
case 199:
this.sendKey(132 | id);
break;
case 200:
this.sendKey(128 | id);
break;
case 201:
case 202:
case 204:
case 206:
case 209:
default:
if (symbol > 0 && symbol <= 127) {
this.sendKey(symbol);
}
break;
case 203:
this.sendKey(130 | id);
break;
case 205:
this.sendKey(131 | id);
break;
case 207:
this.sendKey(133 | id);
break;
case 208:
this.sendKey(129 | id);
break;
case 210:
this.sendKey(134 | id);
}
}
}
public void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(screenTextures);
int l = (super.width - super.xSize) / 2;
int m = (super.height - super.ySize) / 2;
this.drawDoubledRect(l, m, super.xSize, super.ySize, 0, 0, super.xSize, super.ySize);
GL11.glColor4f(0.0F, 1.0F, 0.0F, 1.0F);
for(int y = 0; y < 50; ++y) {
for(int x = 0; x < 80; ++x) {
int b = this.disp.screen[y * 80 + x] & 255;
if (x == this.disp.cursX && y == this.disp.cursY) {
if (this.disp.cursMode == 1) {
b ^= 128;
}
if (this.disp.cursMode == 2) {
long tm = super.mc.theWorld.getWorldTime();
if ((tm >> 2 & 1L) > 0L) {
b ^= 128;
}
}
}
if (b != 32) {
this.drawDoubledRect(l + 15 + x * 4, m + 15 + y * 4, 4, 4, 350 + (b & 15) * 8, (b >> 4) * 8, 8, 8);
}
}
}
}
public void drawDoubledRect(int xPos, int yPos, int width, int heigth, int uStart, int vStart, int uEnd, int vEnd) {
float xm = 0.001953125F;
float ym = 0.00390625F;
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.addVertexWithUV((double)xPos, (double)(yPos + heigth), (double)super.zLevel, (double)((float)uStart * xm), (double)((float)(vStart + vEnd) * ym));
tess.addVertexWithUV(
(double)(xPos + width), (double)(yPos + heigth), (double)super.zLevel, (double)((float)(uStart + uEnd) * xm), (double)((float)(vStart + vEnd) * ym)
);
tess.addVertexWithUV((double)(xPos + width), (double)yPos, (double)super.zLevel, (double)((float)(uStart + uEnd) * xm), (double)((float)vStart * ym));
tess.addVertexWithUV((double)xPos, (double)yPos, (double)super.zLevel, (double)((float)uStart * xm), (double)((float)vStart * ym));
tess.draw();
}
}

View File

@ -0,0 +1,108 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.ItemExtended;
import com.eloraam.redpower.core.RedPowerLib;
import com.eloraam.redpower.core.WorldCoord;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemBackplane extends ItemExtended {
public ItemBackplane(Block block) {
super(block);
}
public boolean onItemUse(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side, float xp, float yp, float zp) {
return !player.isSneaking() && this.itemUseShared(ist, player, world, x, y, z, side);
}
public boolean onItemUseFirst(ItemStack ist, EntityPlayer player, World world, int y, int x, int z, int side, float xp, float yp, float zp) {
return !world.isRemote && player.isSneaking() && this.itemUseShared(ist, player, world, x, y, z, side);
}
protected boolean itemUseShared(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side) {
Block bid = world.getBlock(x, y, z);
int md = world.getBlockMetadata(x, y, z);
int dmg = ist.getItemDamage();
if (bid == Block.getBlockFromItem(ist.getItem()) && md == 0 && dmg != 0) {
TileBackplane bp = CoreLib.getTileEntity(world, x, y, z, TileBackplane.class);
if (bp == null) {
return false;
} else {
int rx = bp.Rotation;
if (!world.setBlock(x, y, z, bid, dmg, 3)) {
return false;
} else {
bp = CoreLib.getTileEntity(world, x, y, z, TileBackplane.class);
if (bp != null) {
bp.Rotation = rx;
}
world.markBlockForUpdate(x, y, z);
CoreLib.placeNoise(world, x, y, z, Block.getBlockFromItem(ist.getItem()));
if (!player.capabilities.isCreativeMode) {
--ist.stackSize;
}
RedPowerLib.updateIndirectNeighbors(world, x, y, z, Block.getBlockFromItem(ist.getItem()));
return true;
}
}
} else if (dmg != 0) {
return false;
} else {
WorldCoord wc = new WorldCoord(x, y, z);
wc.step(side);
if (!world.canPlaceEntityOnSide(Block.getBlockFromItem(ist.getItem()), wc.x, wc.y, wc.z, false, 1, player, ist)) {
return false;
} else if (!RedPowerLib.isSideNormal(world, wc.x, wc.y, wc.z, 0)) {
return false;
} else {
int rx = -1;
label84:
for(int i = 0; i < 4; ++i) {
WorldCoord wc2 = wc.copy();
int dir = CoreLib.rotToSide(i) ^ 1;
wc2.step(dir);
TileCPU cpu = CoreLib.getTileEntity(world, wc2, TileCPU.class);
if (cpu != null && cpu.Rotation == i) {
rx = i;
break;
}
TileBackplane backplane = CoreLib.getTileEntity(world, wc2, TileBackplane.class);
if (backplane != null && backplane.Rotation == i) {
for(int pb = 0; pb < 6; ++pb) {
wc2.step(dir);
if (world.getBlock(wc2.x, wc2.y, wc2.z) == RedPowerControl.blockPeripheral && world.getBlockMetadata(wc2.x, wc2.y, wc2.z) == 1) {
rx = i;
break label84;
}
}
}
}
if (rx < 0) {
return false;
} else if (!world.setBlock(wc.x, wc.y, wc.z, Block.getBlockFromItem(ist.getItem()), dmg, 3)) {
return true;
} else {
TileBackplane bp = CoreLib.getTileEntity(world, wc, TileBackplane.class);
bp.Rotation = rx;
CoreLib.placeNoise(world, wc.x, wc.y, wc.z, Block.getBlockFromItem(ist.getItem()));
if (!player.capabilities.isCreativeMode) {
--ist.stackSize;
}
world.markBlockForUpdate(wc.x, wc.y, wc.z);
RedPowerLib.updateIndirectNeighbors(world, wc.x, wc.y, wc.z, Block.getBlockFromItem(ist.getItem()));
return true;
}
}
}
}
}

View File

@ -0,0 +1,92 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.core.CoreLib;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class ItemDisk extends Item {
private IIcon emptyIcon;
private IIcon forthIcon;
private IIcon forthExtIcon;
public ItemDisk() {
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setMaxStackSize(1);
}
public void registerIcons(IIconRegister reg) {
this.emptyIcon = reg.registerIcon("rpcontrol:disk");
this.forthIcon = reg.registerIcon("rpcontrol:diskForth");
this.forthExtIcon = reg.registerIcon("rpcontrol:diskForthExtended");
}
public String getUnlocalizedName(ItemStack stack) {
switch(stack.getItemDamage()) {
case 0:
return "item.disk";
case 1:
return "item.disk.forth";
case 2:
return "item.disk.forthxp";
default:
return null;
}
}
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(ItemStack ist) {
return ist.stackTagCompound == null
? super.getItemStackDisplayName(ist)
: (!ist.stackTagCompound.hasKey("label") ? super.getItemStackDisplayName(ist) : ist.stackTagCompound.getString("label"));
}
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack ist) {
return ist.getItemDamage() >= 1 ? EnumRarity.uncommon : EnumRarity.common;
}
public boolean onItemUseFirst(ItemStack ist, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
if (!world.isRemote) {
TileDiskDrive tdd = CoreLib.getTileEntity(world, x, y, z, TileDiskDrive.class);
if (tdd != null && tdd.setDisk(ist.copy())) {
ist.stackSize = 0;
tdd.updateBlock();
return true;
}
}
return false;
}
public boolean getShareTag() {
return true;
}
public IIcon getIconFromDamage(int dmg) {
switch(dmg) {
case 1:
return this.forthIcon;
case 2:
return this.forthExtIcon;
default:
return this.emptyIcon;
}
}
public void getSubItems(Item item, CreativeTabs tab, List items) {
for(int i = 0; i <= 2; ++i) {
items.add(new ItemStack(this, 1, i));
}
}
}

View File

@ -0,0 +1,26 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.core.CoverLib;
import com.eloraam.redpower.core.CreativeExtraTabs;
import com.eloraam.redpower.wiring.MicroPlacementWire;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
public class MicroPlacementRibbon extends MicroPlacementWire {
@Override
public String getMicroName(int hb, int lb) {
return hb != 12 && lb != 0 ? null : "tile.ribbon";
}
@Override
public void addCreativeItems(int hb, CreativeTabs tab, List<ItemStack> items) {
if (tab == CreativeExtraTabs.tabWires || tab == CreativeTabs.tabAllSearch) {
switch(hb) {
case 12:
items.add(new ItemStack(CoverLib.blockCoverPlate, 1, 3072));
}
}
}
}

View File

@ -0,0 +1,109 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.RedPowerCore;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderBackplane extends RenderCustomBlock {
private RenderContext context = new RenderContext();
public RenderBackplane(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileBackplane backplane = (TileBackplane)tile;
World world = backplane.getWorldObj();
int metadata = backplane.getBlockMetadata();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.setDefaults();
this.context.bindBlockTexture();
this.context.setBrightness(this.getMixedBrightness(backplane));
this.context.setOrientation(0, backplane.Rotation);
this.context.setPos(x, y, z);
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
tess.startDrawingQuads();
if (metadata == 0) {
this.context
.setIcon(
RedPowerCore.missing,
RedPowerControl.backplaneTop,
RedPowerControl.backplaneFace,
RedPowerControl.backplaneFace,
RedPowerControl.backplaneSide,
RedPowerControl.backplaneSide
);
this.context.renderBox(62, 0.0, 0.0, 0.0, 1.0, 0.125, 1.0);
} else if (metadata == 1) {
this.context
.setIcon(
RedPowerCore.missing,
RedPowerControl.ram8kTop,
RedPowerControl.ram8kFace,
RedPowerControl.ram8kFace,
RedPowerControl.ram8kSide,
RedPowerControl.ram8kSide
);
this.context.renderBox(62, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
}
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
int meta = item.getItemDamage();
Tessellator tess = Tessellator.instance;
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
this.context.useNormal = true;
this.context.setOrientation(0, 3);
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
tess.startDrawingQuads();
if (meta == 0) {
this.context
.setIcon(
RedPowerCore.missing,
RedPowerControl.backplaneTop,
RedPowerControl.backplaneFace,
RedPowerControl.backplaneFace,
RedPowerControl.backplaneSide,
RedPowerControl.backplaneSide
);
this.context.renderBox(62, 0.0, 0.0, 0.0, 1.0, 0.125, 1.0);
} else if (meta == 1) {
this.context
.setIcon(
RedPowerCore.missing,
RedPowerControl.ram8kTop,
RedPowerControl.ram8kFace,
RedPowerControl.ram8kFace,
RedPowerControl.ram8kSide,
RedPowerControl.ram8kSide
);
this.context.renderBox(62, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
}
tess.draw();
this.context.useNormal = false;
}
}

View File

@ -0,0 +1,81 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderCPU extends RenderCustomBlock {
private RenderContext context = new RenderContext();
public RenderCPU(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileCPU cpu = (TileCPU)tile;
World world = cpu.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.bindBlockTexture();
this.context.setDefaults();
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
this.context.setPos(x, y, z);
this.context.readGlobalLights(world, cpu.xCoord, cpu.yCoord, cpu.zCoord);
this.context
.setIcon(
RedPowerControl.peripheralBottom,
RedPowerControl.peripheralTop,
RedPowerControl.peripheralSide,
RedPowerControl.peripheralSide,
RedPowerControl.cpuFront,
RedPowerControl.peripheralBack
);
this.context.setSize(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
this.context.setupBox();
this.context.transform();
this.context.rotateTextures(cpu.Rotation);
tess.startDrawingQuads();
this.context.renderGlobFaces(63);
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Tessellator tess = Tessellator.instance;
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
this.context.useNormal = true;
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.setOrientation(0, 3);
this.context
.setIcon(
RedPowerControl.peripheralBottom,
RedPowerControl.peripheralTop,
RedPowerControl.peripheralSide,
RedPowerControl.peripheralSide,
RedPowerControl.cpuFront,
RedPowerControl.peripheralBack
);
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
tess.startDrawingQuads();
this.context.renderBox(63, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
tess.draw();
this.context.useNormal = false;
}
}

View File

@ -0,0 +1,93 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderDiskDrive extends RenderCustomBlock {
private RenderContext context = new RenderContext();
public RenderDiskDrive(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileDiskDrive diskDrive = (TileDiskDrive)tile;
World world = diskDrive.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.bindBlockTexture();
this.context.setDefaults();
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
this.context.setPos(x, y, z);
this.context.readGlobalLights(world, diskDrive.xCoord, diskDrive.yCoord, diskDrive.zCoord);
IIcon front = RedPowerControl.diskDriveFront;
if (diskDrive.hasDisk) {
front = RedPowerControl.diskDriveFrontFull;
}
if (diskDrive.Active) {
front = RedPowerControl.diskDriveFrontOn;
}
this.context
.setIcon(
RedPowerControl.peripheralBottom,
RedPowerControl.diskDriveTop,
RedPowerControl.diskDriveSide,
RedPowerControl.diskDriveSide,
front,
RedPowerControl.peripheralBack
);
this.context.setTexFlags(512);
this.context.setSize(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
this.context.setupBox();
this.context.transform();
this.context.rotateTextures(diskDrive.Rotation);
tess.startDrawingQuads();
this.context.renderGlobFaces(63);
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Tessellator tess = Tessellator.instance;
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
this.context.useNormal = true;
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.setOrientation(0, 3);
this.context.setTexFlags(512);
this.context
.setIcon(
RedPowerControl.peripheralBottom,
RedPowerControl.diskDriveTop,
RedPowerControl.diskDriveSide,
RedPowerControl.diskDriveSide,
RedPowerControl.diskDriveFront,
RedPowerControl.peripheralBack
);
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
tess.startDrawingQuads();
this.context.renderBox(63, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
tess.draw();
this.context.useNormal = false;
}
}

View File

@ -0,0 +1,81 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderDisplay extends RenderCustomBlock {
private RenderContext context = new RenderContext();
public RenderDisplay(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileDisplay display = (TileDisplay)tile;
World world = display.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.bindBlockTexture();
this.context.setDefaults();
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
this.context.setPos(x, y, z);
this.context.readGlobalLights(world, display.xCoord, display.yCoord, display.zCoord);
this.context
.setIcon(
RedPowerControl.peripheralBottom,
RedPowerControl.peripheralTop,
RedPowerControl.peripheralSide,
RedPowerControl.peripheralSide,
RedPowerControl.displayFront,
RedPowerControl.peripheralBack
);
this.context.setSize(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
this.context.setupBox();
this.context.transform();
this.context.rotateTextures(display.Rotation);
tess.startDrawingQuads();
this.context.renderGlobFaces(63);
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Tessellator tess = Tessellator.instance;
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
this.context.useNormal = true;
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.setOrientation(0, 3);
this.context
.setIcon(
RedPowerControl.peripheralBottom,
RedPowerControl.peripheralTop,
RedPowerControl.peripheralSide,
RedPowerControl.peripheralSide,
RedPowerControl.displayFront,
RedPowerControl.peripheralBack
);
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
tess.startDrawingQuads();
this.context.renderBox(63, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
tess.draw();
this.context.useNormal = false;
}
}

View File

@ -0,0 +1,74 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.RenderContext;
import com.eloraam.redpower.core.RenderCustomBlock;
import com.eloraam.redpower.core.RenderModel;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderIOExpander extends RenderCustomBlock {
private RenderContext context = new RenderContext();
private RenderModel modelModem = RenderModel.loadModel("rpcontrol:models/modem.obj");
private ResourceLocation modelRes = new ResourceLocation("rpcontrol", "models/modem.png");
public RenderIOExpander(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileIOExpander iox = (TileIOExpander)tile;
World world = iox.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
this.context.setDefaults();
this.context.setPos(x, y, z);
this.context.setOrientation(0, iox.Rotation);
this.context.readGlobalLights(world, iox.xCoord, iox.yCoord, iox.zCoord);
this.context.setBrightness(this.getMixedBrightness(iox));
this.context.bindTexture(this.modelRes);
tess.startDrawingQuads();
this.context.bindModelOffset(this.modelModem, 0.5, 0.5, 0.5);
this.context.renderModelGroup(1, 1 + (CoreLib.rotToSide(iox.Rotation) & 1));
this.context.renderModelGroup(2, 1 + (iox.WBuf & 15));
this.context.renderModelGroup(3, 1 + (iox.WBuf >> 4 & 15));
this.context.renderModelGroup(4, 1 + (iox.WBuf >> 8 & 15));
this.context.renderModelGroup(5, 1 + (iox.WBuf >> 12 & 15));
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
super.block.setBlockBoundsForItemRender();
this.context.setDefaults();
if (type == ItemRenderType.INVENTORY) {
this.context.setPos(-0.5, -0.5, -0.5);
} else {
this.context.setPos(0.0, 0.0, 0.0);
}
this.context.bindTexture(this.modelRes);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
this.context.useNormal = true;
this.context.setOrientation(0, 3);
this.context.bindModelOffset(this.modelModem, 0.5, 0.5, 0.5);
this.context.renderModelGroup(1, 1);
this.context.renderModelGroup(2, 1);
this.context.renderModelGroup(3, 1);
this.context.renderModelGroup(4, 1);
this.context.renderModelGroup(5, 1);
this.context.useNormal = false;
tess.draw();
}
}

View File

@ -0,0 +1,70 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.TileCovered;
import com.eloraam.redpower.wiring.RenderWiring;
import com.eloraam.redpower.wiring.TileWiring;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderRibbon extends RenderWiring {
public RenderRibbon(Block block) {
super(block);
}
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
TileCovered covered = (TileCovered)tile;
World world = covered.getWorldObj();
GL11.glDisable(2896);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
super.context.bindBlockTexture();
super.context.setBrightness(this.getMixedBrightness(covered));
super.context.setPos(x, y, z);
if (covered.CoverSides > 0) {
super.context.setTint(1.0F, 1.0F, 1.0F);
super.context.readGlobalLights(world, covered.xCoord, covered.xCoord, covered.zCoord);
this.renderCovers(covered.CoverSides, covered.Covers);
}
TileWiring tw = (TileWiring)covered;
int indcon = tw.getExtConnectionMask();
int cons = tw.getConnectionMask() | indcon;
int indconex = tw.EConEMask;
super.context.setTint(1.0F, 1.0F, 1.0F);
this.setSideIcon(RedPowerControl.ribbonTop, RedPowerControl.ribbonFace, RedPowerControl.ribbonTop);
this.setWireSize(0.5F, 0.0625F);
this.renderWireBlock(tw.ConSides, cons, indcon, indconex);
tess.draw();
GL11.glEnable(2896);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Tessellator tess = Tessellator.instance;
super.block.setBlockBoundsForItemRender();
super.context.setDefaults();
super.context.setTexFlags(55);
if (type == ItemRenderType.INVENTORY) {
super.context.setPos(-0.5, -0.2F, -0.5);
} else {
super.context.setPos(0.0, 0.29999999701976776, 0.0);
}
this.setSideIcon(RedPowerControl.ribbonTop, RedPowerControl.ribbonFace, RedPowerControl.ribbonTop);
this.setWireSize(0.5F, 0.0625F);
super.context.useNormal = true;
tess.startDrawingQuads();
this.renderSideWires(127, 0, 0);
tess.draw();
super.context.useNormal = false;
}
}

View File

@ -0,0 +1,132 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.BlockMultipart;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.IFrameSupport;
import com.eloraam.redpower.core.TileMultipart;
import com.eloraam.redpower.core.WorldCoord;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public class TileBackplane extends TileMultipart implements IFrameSupport {
public int Rotation = 0;
public int readBackplane(int addr) {
return 255;
}
public void writeBackplane(int addr, int val) {
}
public Block getBlockType() {
return RedPowerControl.blockBackplane;
}
@Override
public int getExtendedID() {
return 0;
}
@Override
public void onBlockNeighborChange(Block block) {
if (!super.worldObj
.getBlock(super.xCoord, super.yCoord - 1, super.zCoord)
.isSideSolid(super.worldObj, super.xCoord, super.yCoord - 1, super.zCoord, ForgeDirection.UP)) {
this.breakBlock();
} else {
WorldCoord wc = new WorldCoord(this);
wc.step(CoreLib.rotToSide(this.Rotation) ^ 1);
Block bid = super.worldObj.getBlock(wc.x, wc.y, wc.z);
int md = super.worldObj.getBlockMetadata(wc.x, wc.y, wc.z);
if (bid != RedPowerControl.blockBackplane && (bid != RedPowerControl.blockPeripheral || md != 1)) {
this.breakBlock();
}
}
}
@Override
public void addHarvestContents(List<ItemStack> ist) {
ist.add(new ItemStack(RedPowerControl.blockBackplane, 1, 0));
}
@Override
public void onHarvestPart(EntityPlayer player, int part, boolean willHarvest) {
this.breakBlock(willHarvest);
}
@Override
public float getPartStrength(EntityPlayer player, int part) {
return 0.1F;
}
@Override
public boolean blockEmpty() {
return false;
}
@Override
public void setPartBounds(BlockMultipart block, int part) {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
@Override
public int getSolidPartsMask() {
return 1;
}
@Override
public int getPartsMask() {
return 1;
}
@Override
public void writeFramePacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
}
@Override
public void readFramePacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
}
@Override
public void onFrameRefresh(IBlockAccess iba) {
}
@Override
public void onFramePickup(IBlockAccess iba) {
}
@Override
public void onFrameDrop() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.Rotation = data.getByte("rot");
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByte("rot", (byte)this.Rotation);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,609 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.DiskLib;
import com.eloraam.redpower.core.IFrameSupport;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.MachineLib;
import com.eloraam.redpower.core.TileExtended;
import com.eloraam.redpower.core.WorldCoord;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.IBlockAccess;
public class TileDiskDrive extends TileExtended implements IRedbusConnectable, IInventory, IFrameSupport {
public int Rotation = 0;
public boolean hasDisk = false;
public boolean Active = false;
private ItemStack[] contents = new ItemStack[1];
private int accessTime = 0;
private byte[] databuf = new byte[128];
private int sector = 0;
private int cmdreg = 0;
private int rbaddr = 2;
@Override
public int rbGetAddr() {
return this.rbaddr;
}
@Override
public void rbSetAddr(int addr) {
this.rbaddr = addr;
}
@Override
public int rbRead(int reg) {
if (reg < 128) {
return this.databuf[reg] & 0xFF;
} else {
switch(reg) {
case 128:
return this.sector & 0xFF;
case 129:
return this.sector >> 8;
case 130:
return this.cmdreg & 0xFF;
default:
return 0;
}
}
}
@Override
public void rbWrite(int reg, int dat) {
this.markDirty();
if (reg < 128) {
this.databuf[reg] = (byte)dat;
} else {
switch(reg) {
case 128:
this.sector = this.sector & 0xFF00 | dat;
break;
case 129:
this.sector = this.sector & 0xFF | dat << 8;
break;
case 130:
this.cmdreg = dat;
}
}
}
@Override
public int getConnectableMask() {
return 16777215;
}
@Override
public int getConnectClass(int side) {
return 66;
}
@Override
public int getCornerPowerMode() {
return 0;
}
@Override
public void onBlockPlaced(ItemStack ist, int side, EntityLivingBase ent) {
this.Rotation = (int)Math.floor((double)(ent.rotationYaw * 4.0F / 360.0F) + 0.5) + 1 & 3;
if (ent instanceof EntityPlayer) {
super.Owner = ((EntityPlayer)ent).getGameProfile();
}
}
@Override
public boolean onBlockActivated(EntityPlayer player) {
if (!super.worldObj.isRemote) {
if (this.hasDisk && this.contents[0] != null && !this.Active) {
this.ejectDisk();
return true;
} else {
return false;
}
} else {
return true;
}
}
public Block getBlockType() {
return RedPowerControl.blockPeripheral;
}
@Override
public int getExtendedID() {
return 2;
}
@Override
public void onBlockRemoval() {
for(int i = 0; i < 1; ++i) {
ItemStack ist = this.contents[i];
if (ist != null && ist.stackSize > 0) {
CoreLib.dropItem(super.worldObj, super.xCoord, super.yCoord, super.zCoord, ist);
}
}
}
boolean setDisk(ItemStack ist) {
if (this.contents[0] != null) {
return false;
} else {
this.setInventorySlotContents(0, ist);
return true;
}
}
private NBTTagCompound getDiskTags() {
NBTTagCompound tags = this.contents[0].stackTagCompound;
if (tags == null) {
this.contents[0].setTagCompound(new NBTTagCompound());
tags = this.contents[0].stackTagCompound;
}
return tags;
}
private File startDisk() {
if (this.contents[0].getItemDamage() > 0) {
return null;
} else {
NBTTagCompound tags = this.getDiskTags();
File savedir = DiskLib.getSaveDir(super.worldObj);
if (tags.hasKey("serno")) {
return DiskLib.getDiskFile(savedir, tags.getString("serno"));
} else {
String serno = null;
while(true) {
serno = DiskLib.generateSerialNumber(super.worldObj);
File diskFile = DiskLib.getDiskFile(savedir, serno);
try {
if (diskFile.createNewFile()) {
tags.setString("serno", serno);
return diskFile;
}
} catch (IOException var6) {
var6.printStackTrace();
return null;
}
}
}
}
}
private void runCmd1() {
Arrays.fill(this.databuf, (byte)0);
String nm = "";
if (this.contents[0].getItemDamage() > 0) {
nm = "System Disk";
} else {
NBTTagCompound e = this.contents[0].stackTagCompound;
if (e == null) {
return;
}
nm = e.getString("label");
}
try {
byte[] e1 = nm.getBytes("US-ASCII");
System.arraycopy(e1, 0, this.databuf, 0, Math.min(e1.length, 128));
} catch (UnsupportedEncodingException var3) {
}
}
private void runCmd2() {
if (this.contents[0].getItemDamage() > 0) {
this.cmdreg = -1;
} else {
NBTTagCompound tags = this.getDiskTags();
int len = 0;
while(this.databuf[len] != 0 && len < 64) {
++len;
}
this.cmdreg = 0;
try {
String e = new String(this.databuf, 0, len, "US-ASCII");
tags.setString("label", e);
} catch (UnsupportedEncodingException var4) {
}
}
}
private void runCmd3() {
Arrays.fill(this.databuf, (byte)0);
String nm = "";
if (this.contents[0].getItemDamage() > 0) {
nm = String.format("%016d", this.contents[0].getItemDamage());
} else {
NBTTagCompound e = this.getDiskTags();
this.startDisk();
if (e == null) {
return;
}
nm = e.getString("serno");
}
try {
byte[] e1 = nm.getBytes("US-ASCII");
System.arraycopy(e1, 0, this.databuf, 0, Math.min(e1.length, 128));
} catch (UnsupportedEncodingException var3) {
}
}
private void runCmd4() {
if (this.sector > 2048) {
this.cmdreg = -1;
} else {
long l = (long)(this.sector * 128);
if (this.contents[0].getItemDamage() > 0) {
InputStream file = null;
switch(this.contents[0].getItemDamage()) {
case 1:
file = RedPowerControl.class.getResourceAsStream("/assets/rpcontrol/forth/redforth.img");
break;
case 2:
file = RedPowerControl.class.getResourceAsStream("/assets/rpcontrol/forth/redforthxp.img");
}
try {
if (file.skip(l) == l) {
if (file.read(this.databuf) == 128) {
this.cmdreg = 0;
return;
}
this.cmdreg = -1;
return;
}
this.cmdreg = -1;
} catch (IOException var36) {
var36.printStackTrace();
this.cmdreg = -1;
return;
} finally {
try {
if (file != null) {
file.close();
}
} catch (IOException var33) {
}
}
return;
} else {
File file1 = this.startDisk();
if (file1 == null) {
this.cmdreg = -1;
} else {
RandomAccessFile raf = null;
try {
raf = new RandomAccessFile(file1, "r");
raf.seek(l);
if (raf.read(this.databuf) == 128) {
this.cmdreg = 0;
return;
}
this.cmdreg = -1;
} catch (IOException var34) {
var34.printStackTrace();
this.cmdreg = -1;
} finally {
try {
if (raf != null) {
raf.close();
}
} catch (IOException var32) {
}
}
}
}
}
}
private void runCmd5() {
if (this.contents[0].getItemDamage() > 0) {
this.cmdreg = -1;
} else if (this.sector > 2048) {
this.cmdreg = -1;
} else {
long l = (long)(this.sector * 128);
File file = this.startDisk();
if (file == null) {
this.cmdreg = -1;
} else {
RandomAccessFile raf = null;
try {
raf = new RandomAccessFile(file, "rw");
raf.seek(l);
raf.write(this.databuf);
raf.close();
raf = null;
this.cmdreg = 0;
} catch (IOException var14) {
this.cmdreg = -1;
} finally {
try {
if (raf != null) {
raf.close();
}
} catch (IOException var13) {
}
}
}
}
}
private void runDiskCmd() {
this.markDirty();
if (this.contents[0] == null) {
this.cmdreg = -1;
} else if (!(this.contents[0].getItem() instanceof ItemDisk)) {
this.cmdreg = -1;
} else {
switch(this.cmdreg) {
case 1:
this.runCmd1();
this.cmdreg = 0;
break;
case 2:
this.runCmd2();
break;
case 3:
this.runCmd3();
this.cmdreg = 0;
break;
case 4:
this.runCmd4();
break;
case 5:
this.runCmd5();
break;
default:
this.cmdreg = -1;
}
this.accessTime = 5;
if (!this.Active) {
this.Active = true;
this.updateBlock();
}
}
}
private void ejectDisk() {
if (this.contents[0] != null) {
MachineLib.ejectItem(super.worldObj, new WorldCoord(this), this.contents[0], CoreLib.rotToSide(this.Rotation) ^ 1);
this.contents[0] = null;
this.hasDisk = false;
this.updateBlock();
}
}
public void markDirty() {
super.markDirty();
if (this.contents[0] != null && !(this.contents[0].getItem() instanceof ItemDisk)) {
this.ejectDisk();
}
}
@Override
public void updateEntity() {
if (this.cmdreg != 0 && this.cmdreg != -1) {
this.runDiskCmd();
}
if (this.accessTime > 0 && --this.accessTime == 0) {
this.Active = false;
this.updateBlock();
}
}
public int getSizeInventory() {
return 1;
}
public ItemStack getStackInSlot(int i) {
return this.contents[i];
}
public ItemStack decrStackSize(int i, int j) {
if (this.contents[i] == null) {
return null;
} else if (this.contents[i].stackSize <= j) {
ItemStack tr = this.contents[i];
this.contents[i] = null;
this.markDirty();
return tr;
} else {
ItemStack tr = this.contents[i].splitStack(j);
if (this.contents[i].stackSize == 0) {
this.contents[i] = null;
}
this.markDirty();
return tr;
}
}
public ItemStack getStackInSlotOnClosing(int i) {
if (this.contents[i] == null) {
return null;
} else {
ItemStack ist = this.contents[i];
this.contents[i] = null;
return ist;
}
}
public void setInventorySlotContents(int i, ItemStack ist) {
this.contents[i] = ist;
if (ist != null && ist.stackSize > this.getInventoryStackLimit()) {
ist.stackSize = this.getInventoryStackLimit();
}
this.markDirty();
this.hasDisk = this.contents[i] != null;
this.updateBlock();
}
public String getInventoryName() {
return "tile.rpdiskdrive.name";
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer player) {
return !this.isInvalid()
&& super.worldObj.getTileEntity(super.xCoord, super.yCoord, super.zCoord) == this
&& player.getDistanceSq((double)super.xCoord + 0.5, (double)super.yCoord + 0.5, (double)super.zCoord + 0.5) <= 64.0;
}
@Override
public void writeFramePacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
tag.setByte("fl", (byte)((this.hasDisk ? 1 : 0) | (this.Active ? 2 : 0)));
}
@Override
public void readFramePacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
int fl = tag.getByte("fl");
this.hasDisk = (fl & 1) > 0;
this.Active = (fl & 2) > 0;
}
@Override
public void onFrameRefresh(IBlockAccess iba) {
}
@Override
public void onFramePickup(IBlockAccess iba) {
}
@Override
public void onFrameDrop() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.Rotation = data.getByte("rot");
this.accessTime = data.getByte("actime");
this.sector = data.getShort("sect");
this.cmdreg = data.getByte("cmd") & 255;
this.rbaddr = data.getByte("rbaddr") & 255;
byte fl = data.getByte("fl");
this.hasDisk = (fl & 1) > 0;
this.Active = (fl & 2) > 0;
this.databuf = data.getByteArray("dbuf");
if (this.databuf.length != 128) {
this.databuf = new byte[128];
}
NBTTagList items = data.getTagList("Items", 10);
this.contents = new ItemStack[this.getSizeInventory()];
for(int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
int j = item.getByte("Slot") & 255;
if (j >= 0 && j < this.contents.length) {
this.contents[j] = ItemStack.loadItemStackFromNBT(item);
}
}
this.hasDisk = this.contents[0] != null;
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByte("rot", (byte)this.Rotation);
int fl = (this.hasDisk ? 1 : 0) | (this.Active ? 2 : 0);
data.setByte("fl", (byte)fl);
data.setByte("actime", (byte)this.accessTime);
data.setByteArray("dbuf", this.databuf);
data.setShort("sect", (short)this.sector);
data.setByte("cmd", (byte)this.cmdreg);
data.setByte("rbaddr", (byte)this.rbaddr);
NBTTagList items = new NBTTagList();
for(int i = 0; i < this.contents.length; ++i) {
if (this.contents[i] != null) {
NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte)i);
this.contents[i].writeToNBT(item);
items.appendTag(item);
}
}
data.setTag("Items", items);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
int fl = tag.getByte("fl");
this.hasDisk = (fl & 1) > 0;
this.Active = (fl & 2) > 0;
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
tag.setByte("fl", (byte)((this.hasDisk ? 1 : 0) | (this.Active ? 2 : 0)));
}
public boolean hasCustomInventoryName() {
return false;
}
public void openInventory() {
}
public void closeInventory() {
}
public boolean isItemValidForSlot(int slotID, ItemStack stack) {
return slotID == 0 && stack.getItem() instanceof ItemDisk;
}
}

View File

@ -0,0 +1,346 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.IFrameSupport;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.TileExtended;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
public class TileDisplay extends TileExtended implements IRedbusConnectable, IFrameSupport {
public byte[] screen = new byte[4000];
public int Rotation = 0;
public int memRow = 0;
public int cursX = 0;
public int cursY = 0;
public int cursMode = 2;
public int kbstart = 0;
public int kbpos = 0;
public int blitXS = 0;
public int blitYS = 0;
public int blitXD = 0;
public int blitYD = 0;
public int blitW = 0;
public int blitH = 0;
public int blitMode = 0;
public byte[] kbbuf = new byte[16];
private int rbaddr = 1;
public TileDisplay() {
Arrays.fill(this.screen, (byte)32);
}
@Override
public int rbGetAddr() {
return this.rbaddr;
}
@Override
public void rbSetAddr(int addr) {
this.rbaddr = addr;
}
@Override
public int rbRead(int reg) {
if (reg >= 16 && reg < 96) {
return this.screen[this.memRow * 80 + reg - 16];
} else {
switch(reg) {
case 0:
return this.memRow;
case 1:
return this.cursX;
case 2:
return this.cursY;
case 3:
return this.cursMode;
case 4:
return this.kbstart;
case 5:
return this.kbpos;
case 6:
return this.kbbuf[this.kbstart] & 0xFF;
case 7:
return this.blitMode;
case 8:
return this.blitXS;
case 9:
return this.blitYS;
case 10:
return this.blitXD;
case 11:
return this.blitYD;
case 12:
return this.blitW;
case 13:
return this.blitH;
default:
return 0;
}
}
}
@Override
public void rbWrite(int reg, int dat) {
this.markDirty();
if (reg >= 16 && reg < 96) {
this.screen[this.memRow * 80 + reg - 16] = (byte)dat;
} else {
switch(reg) {
case 0:
this.memRow = dat;
if (this.memRow > 49) {
this.memRow = 49;
}
return;
case 1:
this.cursX = dat;
return;
case 2:
this.cursY = dat;
return;
case 3:
this.cursMode = dat;
return;
case 4:
this.kbstart = dat & 15;
return;
case 5:
this.kbpos = dat & 15;
return;
case 6:
this.kbbuf[this.kbstart] = (byte)dat;
return;
case 7:
this.blitMode = dat;
return;
case 8:
this.blitXS = dat;
return;
case 9:
this.blitYS = dat;
return;
case 10:
this.blitXD = dat;
return;
case 11:
this.blitYD = dat;
return;
case 12:
this.blitW = dat;
return;
case 13:
this.blitH = dat;
return;
}
}
}
@Override
public int getConnectableMask() {
return 16777215;
}
@Override
public int getConnectClass(int side) {
return 66;
}
@Override
public int getCornerPowerMode() {
return 0;
}
@Override
public void onBlockPlaced(ItemStack ist, int side, EntityLivingBase ent) {
this.Rotation = (int)Math.floor((double)(ent.rotationYaw * 4.0F / 360.0F) + 0.5) + 1 & 3;
if (ent instanceof EntityPlayer) {
super.Owner = ((EntityPlayer)ent).getGameProfile();
}
}
@Override
public boolean onBlockActivated(EntityPlayer player) {
if (!super.worldObj.isRemote) {
player.openGui(RedPowerControl.instance, 1, super.worldObj, super.xCoord, super.yCoord, super.zCoord);
}
return true;
}
public Block getBlockType() {
return RedPowerControl.blockPeripheral;
}
@Override
public int getExtendedID() {
return 0;
}
public boolean isUseableByPlayer(EntityPlayer player) {
return !this.isInvalid()
&& super.worldObj.getTileEntity(super.xCoord, super.yCoord, super.zCoord) == this
&& player.getDistanceSq((double)super.xCoord + 0.5, (double)super.yCoord + 0.5, (double)super.zCoord + 0.5) <= 64.0;
}
public void pushKey(byte b) {
int np = this.kbpos + 1 & 15;
if (np != this.kbstart) {
this.kbbuf[this.kbpos] = b;
this.kbpos = np;
}
}
@Override
public void updateEntity() {
this.runblitter();
}
private void runblitter() {
if (this.blitMode != 0) {
this.markDirty();
int w = this.blitW;
int h = this.blitH;
w = Math.min(w, 80 - this.blitXD);
h = Math.min(h, 50 - this.blitYD);
if (w >= 0 && h >= 0) {
int doffs = this.blitYD * 80 + this.blitXD;
switch(this.blitMode) {
case 1:
for(int soffs = 0; soffs < h; ++soffs) {
for(int j = 0; j < w; ++j) {
this.screen[doffs + 80 * soffs + j] = (byte)this.blitXS;
}
}
this.blitMode = 0;
return;
case 2:
for(int soffs = 0; soffs < h; ++soffs) {
for(int j = 0; j < w; ++j) {
this.screen[doffs + 80 * soffs + j] = (byte)(this.screen[doffs + 80 * soffs + j] ^ 128);
}
}
this.blitMode = 0;
return;
}
w = Math.min(w, 80 - this.blitXS);
h = Math.min(h, 50 - this.blitYS);
if (w >= 0 && h >= 0) {
int soffs = this.blitYS * 80 + this.blitXS;
switch(this.blitMode) {
case 3:
for(int j = 0; j < h; ++j) {
for(int i = 0; i < w; ++i) {
this.screen[doffs + 80 * j + i] = this.screen[soffs + 80 * j + i];
}
}
this.blitMode = 0;
return;
}
} else {
this.blitMode = 0;
}
} else {
this.blitMode = 0;
}
}
}
@Override
public void writeFramePacket(NBTTagCompound tag) {
tag.setInteger("rot", this.Rotation);
}
@Override
public void readFramePacket(NBTTagCompound tag) {
this.Rotation = tag.getInteger("rot");
}
@Override
public void onFrameRefresh(IBlockAccess iba) {
}
@Override
public void onFramePickup(IBlockAccess iba) {
}
@Override
public void onFrameDrop() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.Rotation = data.getByte("rot");
this.screen = data.getByteArray("fb");
if (this.screen.length != 4000) {
this.screen = new byte[4000];
}
this.memRow = data.getByte("row") & 255;
this.cursX = data.getByte("cx") & 255;
this.cursY = data.getByte("cy") & 255;
this.cursMode = data.getByte("cm") & 255;
this.kbstart = data.getByte("kbs");
this.kbpos = data.getByte("kbp");
this.kbbuf = data.getByteArray("kbb");
if (this.kbbuf.length != 16) {
this.kbbuf = new byte[16];
}
this.blitXS = data.getByte("blxs") & 255;
this.blitYS = data.getByte("blys") & 255;
this.blitXD = data.getByte("blxd") & 255;
this.blitYD = data.getByte("blyd") & 255;
this.blitW = data.getByte("blw") & 255;
this.blitH = data.getByte("blh") & 255;
this.blitMode = data.getByte("blmd");
this.rbaddr = data.getByte("rbaddr") & 255;
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByte("rot", (byte)this.Rotation);
data.setByteArray("fb", this.screen);
data.setByte("row", (byte)this.memRow);
data.setByte("cx", (byte)this.cursX);
data.setByte("cy", (byte)this.cursY);
data.setByte("cm", (byte)this.cursMode);
data.setByte("kbs", (byte)this.kbstart);
data.setByte("kbp", (byte)this.kbpos);
data.setByteArray("kbb", this.kbbuf);
data.setByte("blxs", (byte)this.blitXS);
data.setByte("blys", (byte)this.blitYS);
data.setByte("blxd", (byte)this.blitXD);
data.setByte("blyd", (byte)this.blitYD);
data.setByte("blw", (byte)this.blitW);
data.setByte("blh", (byte)this.blitH);
data.setByte("blmd", (byte)this.blitMode);
data.setByte("rbaddr", (byte)this.rbaddr);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
this.Rotation = tag.getInteger("rot");
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
tag.setInteger("rot", this.Rotation);
}
}

View File

@ -0,0 +1,231 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.BlockMultipart;
import com.eloraam.redpower.core.CoreLib;
import com.eloraam.redpower.core.IFrameSupport;
import com.eloraam.redpower.core.IRedPowerConnectable;
import com.eloraam.redpower.core.IRedbusConnectable;
import com.eloraam.redpower.core.RedPowerLib;
import com.eloraam.redpower.core.TileMultipart;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
public class TileIOExpander extends TileMultipart implements IRedbusConnectable, IRedPowerConnectable, IFrameSupport {
public int Rotation = 0;
public int WBuf = 0;
public int WBufNew = 0;
public int RBuf = 0;
private int rbaddr = 3;
@Override
public int rbGetAddr() {
return this.rbaddr;
}
@Override
public void rbSetAddr(int addr) {
this.rbaddr = addr;
}
@Override
public int rbRead(int reg) {
switch(reg) {
case 0:
return this.RBuf & 0xFF;
case 1:
return this.RBuf >> 8;
case 2:
return this.WBufNew & 0xFF;
case 3:
return this.WBufNew >> 8;
default:
return 0;
}
}
@Override
public void rbWrite(int reg, int dat) {
this.markDirty();
switch(reg) {
case 0:
case 2:
this.WBufNew = this.WBufNew & 0xFF00 | dat;
this.scheduleTick(2);
break;
case 1:
case 3:
this.WBufNew = this.WBufNew & 0xFF | dat << 8;
this.scheduleTick(2);
}
}
@Override
public int getConnectableMask() {
return 15;
}
@Override
public int getConnectClass(int side) {
return side == CoreLib.rotToSide(this.Rotation) ? 18 : 66;
}
@Override
public int getCornerPowerMode() {
return 0;
}
@Override
public int getPoweringMask(int ch) {
return ch == 0 ? 0 : ((this.WBuf & 1 << ch - 1) > 0 ? RedPowerLib.mapRotToCon(8, this.Rotation) : 0);
}
@Override
public void onBlockPlaced(ItemStack ist, int side, EntityLivingBase ent) {
this.Rotation = (int)Math.floor((double)(ent.rotationYaw * 4.0F / 360.0F) + 0.5) + 1 & 3;
if (ent instanceof EntityPlayer) {
super.Owner = ((EntityPlayer)ent).getGameProfile();
}
}
@Override
public void onTileTick() {
if (this.WBuf != this.WBufNew) {
this.WBuf = this.WBufNew;
this.onBlockNeighborChange(Blocks.air);
this.updateBlockChange();
}
}
@Override
public void onBlockNeighborChange(Block block) {
boolean ch = false;
for(int n = 0; n < 16; ++n) {
int ps = RedPowerLib.getRotPowerState(super.worldObj, super.xCoord, super.yCoord, super.zCoord, 8, this.Rotation, n + 1);
if (ps == 0) {
if ((this.RBuf & 1 << n) > 0) {
this.RBuf &= ~(1 << n);
ch = true;
}
} else if ((this.RBuf & 1 << n) == 0) {
this.RBuf |= 1 << n;
ch = true;
}
}
if (ch) {
this.updateBlock();
}
}
public Block getBlockType() {
return RedPowerControl.blockFlatPeripheral;
}
@Override
public int getExtendedID() {
return 0;
}
@Override
public void addHarvestContents(List<ItemStack> ist) {
ist.add(new ItemStack(this.getBlockType(), 1, 0));
}
@Override
public void onHarvestPart(EntityPlayer player, int part, boolean willHarvest) {
this.breakBlock(willHarvest);
}
@Override
public float getPartStrength(EntityPlayer player, int part) {
return 0.1F;
}
@Override
public boolean blockEmpty() {
return false;
}
@Override
public void setPartBounds(BlockMultipart block, int part) {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
@Override
public int getSolidPartsMask() {
return 1;
}
@Override
public int getPartsMask() {
return 1;
}
@Override
public void writeFramePacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
tag.setShort("wb", (short)this.WBuf);
}
@Override
public void readFramePacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
this.WBuf = tag.getShort("wb");
}
@Override
public void onFrameRefresh(IBlockAccess iba) {
}
@Override
public void onFramePickup(IBlockAccess iba) {
}
@Override
public void onFrameDrop() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.Rotation = data.getByte("rot");
this.WBuf = data.getShort("wb");
this.WBufNew = data.getShort("wbn");
this.RBuf = data.getShort("rb");
this.rbaddr = data.getByte("rbaddr") & 255;
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByte("rot", (byte)this.Rotation);
data.setShort("wb", (short)this.WBuf);
data.setShort("wbn", (short)this.WBufNew);
data.setShort("rb", (short)this.RBuf);
data.setByte("rbaddr", (byte)this.rbaddr);
}
@Override
protected void readFromPacket(NBTTagCompound tag) {
this.Rotation = tag.getByte("rot");
this.WBuf = tag.getShort("wb");
}
@Override
protected void writeToPacket(NBTTagCompound tag) {
tag.setByte("rot", (byte)this.Rotation);
tag.setShort("wb", (short)this.WBuf);
}
}

View File

@ -0,0 +1,91 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.RedPowerControl;
import com.eloraam.redpower.core.BlockMultipart;
import com.eloraam.redpower.core.CoreLib;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class TileRAM extends TileBackplane {
public byte[] memory = new byte[8192];
@Override
public int readBackplane(int addr) {
return this.memory[addr] & 0xFF;
}
@Override
public void writeBackplane(int addr, int val) {
this.memory[addr] = (byte)val;
}
@Override
public Block getBlockType() {
return RedPowerControl.blockBackplane;
}
@Override
public int getExtendedID() {
return 1;
}
@Override
public void addHarvestContents(List<ItemStack> ist) {
ist.add(new ItemStack(RedPowerControl.blockBackplane, 1, 0));
ist.add(new ItemStack(RedPowerControl.blockBackplane, 1, 1));
}
@Override
public void onHarvestPart(EntityPlayer player, int part, boolean willHarvest) {
if (willHarvest) {
CoreLib.dropItem(super.worldObj, super.xCoord, super.yCoord, super.zCoord, new ItemStack(RedPowerControl.blockBackplane, 1, 1));
}
super.worldObj.setBlock(super.xCoord, super.yCoord, super.zCoord, RedPowerControl.blockBackplane);
TileBackplane tb = CoreLib.getTileEntity(super.worldObj, super.xCoord, super.yCoord, super.zCoord, TileBackplane.class);
if (tb != null) {
tb.Rotation = super.Rotation;
}
this.updateBlockChange();
}
@Override
public void setPartBounds(BlockMultipart block, int part) {
if (part == 0) {
super.setPartBounds(block, part);
} else {
block.setBlockBounds(0.0F, 0.125F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@Override
public int getSolidPartsMask() {
return 3;
}
@Override
public int getPartsMask() {
return 3;
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.memory = data.getByteArray("ram");
if (this.memory.length != 8192) {
this.memory = new byte[8192];
}
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByteArray("ram", this.memory);
}
}

View File

@ -0,0 +1,23 @@
package com.eloraam.redpower.control;
import com.eloraam.redpower.wiring.TileWiring;
import net.minecraft.block.Block;
public class TileRibbon extends TileWiring {
@Override
public int getExtendedID() {
return 12;
}
@Override
public int getConnectClass(int side) {
return 66;
}
@Override
public void onBlockNeighborChange(Block block) {
super.onBlockNeighborChange(block);
this.getConnectionMask();
this.getExtConnectionMask();
}
}

View File

@ -0,0 +1,94 @@
package com.eloraam.redpower.core;
import java.util.HashMap;
import java.util.TreeMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage;
public class AchieveLib {
private static HashMap<String, Achievement> achievelist = new HashMap();
public static AchievementPage achievepage = new AchievementPage("RedPower", new Achievement[0]);
private static TreeMap<ItemStack, Achievement> achievebycraft = new TreeMap<>(CoreLib::compareItemStack);
private static TreeMap<ItemStack, Achievement> achievebyfurnace = new TreeMap<>(CoreLib::compareItemStack);
private static TreeMap<ItemStack, Achievement> achievebyalloy = new TreeMap<>(CoreLib::compareItemStack);
public static void registerAchievement(String name, int x, int y, ItemStack icon, Object require, boolean special) {
Achievement acreq = null;
if (require instanceof Achievement) {
acreq = (Achievement)require;
} else if (require instanceof String) {
acreq = (Achievement)achievelist.get(require);
}
Achievement ac = new Achievement(name, name, x, y, icon, acreq);
ac.registerStat();
if (special) {
ac.setSpecial();
}
achievelist.put(name, ac);
achievepage.getAchievements().add(ac);
}
public static void registerAchievement(String name, int x, int y, ItemStack icon, Object require) {
registerAchievement(name, x, y, icon, require, false);
}
public static void addCraftingAchievement(ItemStack target, String id) {
Achievement ac = (Achievement)achievelist.get(id);
if (ac != null) {
achievebycraft.put(target, ac);
}
}
public static void addAlloyAchievement(ItemStack target, String id) {
Achievement ac = (Achievement)achievelist.get(id);
if (ac != null) {
achievebyalloy.put(target, ac);
}
}
public static void addFurnaceAchievement(ItemStack target, String id) {
Achievement ac = (Achievement)achievelist.get(id);
if (ac != null) {
achievebyfurnace.put(target, ac);
}
}
public static void triggerAchievement(EntityPlayer player, String id) {
Achievement ac = (Achievement)achievelist.get(id);
if (ac != null) {
player.triggerAchievement(ac);
}
}
public static void onCrafting(EntityPlayer player, ItemStack ist) {
Achievement ac = (Achievement)achievebycraft.get(ist);
if (ac != null) {
player.triggerAchievement(ac);
}
}
public static void onFurnace(EntityPlayer player, ItemStack ist) {
Achievement ac = (Achievement)achievebyfurnace.get(ist);
if (ac != null) {
player.triggerAchievement(ac);
}
}
public static void onAlloy(EntityPlayer player, ItemStack ist) {
Achievement ac = (Achievement)achievebyalloy.get(ist);
if (ac != null) {
player.triggerAchievement(ac);
}
}
}

View File

@ -0,0 +1,50 @@
package com.eloraam.redpower.core;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class BlockCoverable extends BlockMultipart {
public BlockCoverable(Material material) {
super(material);
}
public boolean isSideSolid(IBlockAccess world, int i, int j, int k, ForgeDirection side) {
TileCoverable tc = CoreLib.getTileEntity(world, i, j, k, TileCoverable.class);
return tc != null && tc.isSideNormal(side.ordinal());
}
public float getExplosionResistance(Entity exploder, World world, int x, int y, int z, double srcX, double srcY, double srcZ) {
Vec3 org = Vec3.createVectorHelper(srcX, srcY, srcZ);
Vec3 end = Vec3.createVectorHelper((double)x + 0.5, (double)y + 0.5, (double)z + 0.5);
Block bl = world.getBlock(x, y, z);
if (bl == null) {
return 0.0F;
} else {
MovingObjectPosition mop = bl.collisionRayTrace(world, x, y, z, org, end);
if (mop == null) {
return bl.getExplosionResistance(exploder);
} else {
TileCoverable tl = CoreLib.getTileEntity(world, x, y, z, TileCoverable.class);
if (tl == null) {
return bl.getExplosionResistance(exploder);
} else {
float er = tl.getExplosionResistance(mop.subHit, mop.sideHit, exploder);
return er < 0.0F ? bl.getExplosionResistance(exploder) : er;
}
}
}
}
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
TileCoverable tile = CoreLib.getTileEntity(world, x, y, z, TileCoverable.class);
return tile != null ? tile.getPickBlock(target, player) : null;
}
}

View File

@ -0,0 +1,212 @@
package com.eloraam.redpower.core;
import com.eloraam.redpower.RedPowerCore;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Random;
import java.util.function.Supplier;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockExtended extends BlockContainer {
private Supplier<? extends TileExtended>[] tileEntityMap = new Supplier[16];
public BlockExtended(Material m) {
super(m);
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public boolean isFullCube() {
return false;
}
public int damageDropped(int i) {
return i;
}
public float getHardness() {
return super.blockHardness;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
}
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
ArrayList<ItemStack> ist = new ArrayList();
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
if (tl == null) {
return ist;
} else {
tl.addHarvestContents(ist);
return ist;
}
}
public Item getItemDropped(int i, Random random, int j) {
return Item.getItemFromBlock(Blocks.air);
}
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int side) {
}
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (!world.isRemote) {
Block bl = world.getBlock(x, y, z);
int md = world.getBlockMetadata(x, y, z);
if (bl == null) {
return false;
} else {
if (bl.canHarvestBlock(player, md) && willHarvest) {
for(ItemStack it : this.getDrops(world, x, y, z, md, EnchantmentHelper.getFortuneModifier(player))) {
CoreLib.dropItem(world, x, y, z, it);
}
}
world.setBlockToAir(x, y, z);
return true;
}
} else {
return true;
}
}
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
if (tl == null) {
world.setBlockToAir(x, y, z);
} else {
tl.onBlockNeighborChange(block);
}
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
return super.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, meta);
}
public void onBlockPlacedBy(World world, int x, int y, int z, int side, EntityLivingBase ent, ItemStack ist) {
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
if (tl != null) {
tl.onBlockPlaced(ist, side, ent);
}
}
public void breakBlock(World world, int x, int y, int z, Block block, int md) {
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
if (tl != null) {
tl.onBlockRemoval();
super.breakBlock(world, x, y, z, block, md);
}
}
public int isProvidingStrongPower(IBlockAccess iba, int x, int y, int z, int side) {
TileExtended tl = CoreLib.getTileEntity(iba, x, y, z, TileExtended.class);
return tl != null && tl.isBlockStrongPoweringTo(side) ? 15 : 0;
}
public int isProvidingWeakPower(IBlockAccess iba, int x, int y, int z, int side) {
TileExtended tl = CoreLib.getTileEntity(iba, x, y, z, TileExtended.class);
return tl != null && tl.isBlockWeakPoweringTo(side) ? 1 : 0;
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xp, float yp, float zp) {
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
return tl != null && tl.onBlockActivated(player);
}
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
if (tl != null) {
tl.onEntityCollidedWithBlock(entity);
}
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
TileExtended tl = CoreLib.getTileEntity(world, x, y, z, TileExtended.class);
if (tl != null) {
AxisAlignedBB bb = tl.getCollisionBoundingBox();
if (bb != null) {
return bb;
}
}
this.setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}
public int getRenderType() {
return RedPowerCore.customBlockModel;
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
int md = world.getBlockMetadata(x, y, z);
RenderCustomBlock rend = RenderLib.getRenderer(this, md);
if (rend != null) {
rend.randomDisplayTick(world, x, y, z, random);
}
}
public void addTileEntityMapping(int md, Supplier<? extends TileExtended> cl) {
this.tileEntityMap[md] = cl;
}
public void setBlockName(int md, String name) {
Item item = Item.getItemFromBlock(this);
((ItemExtended)item).setMetaName(md, "tile." + name);
}
public TileEntity createNewTileEntity(World world, int md) {
return this.tileEntityMap[md] != null ? (TileEntity)this.tileEntityMap[md].get() : null;
}
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer) {
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
int meta = world.getBlockMetadata(x, y, z);
int side = target.sideHit;
RenderCustomBlock renderer = RenderLib.getRenderer(this, meta);
return renderer != null && renderer.renderHit(effectRenderer, world, target, x, y, z, side, meta);
}
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
RenderCustomBlock renderer = RenderLib.getRenderer(this, meta);
return renderer != null && renderer.renderDestroy(effectRenderer, world, x, y, z, meta);
}
}

View File

@ -0,0 +1,106 @@
package com.eloraam.redpower.core;
import com.eloraam.redpower.RedPowerCore;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockMultiblock extends BlockContainer {
public BlockMultiblock() {
super(CoreLib.materialRedpower);
}
public void registerBlockIcons(IIconRegister reg) {
}
public int getRenderType() {
return RedPowerCore.nullBlockModel;
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList();
}
public TileEntity createNewTileEntity(World worldObj, int metadata) {
return null;
}
public TileEntity createTileEntity(World worldObj, int metadata) {
switch(metadata) {
case 0:
return new TileMultiblock();
default:
return null;
}
}
public void breakBlock(World world, int x, int y, int z, Block block, int md) {
TileMultiblock tmb = CoreLib.getTileEntity(world, x, y, z, TileMultiblock.class);
if (tmb != null) {
IMultiblock imb = CoreLib.getTileEntity(world, tmb.relayX, tmb.relayY, tmb.relayZ, IMultiblock.class);
if (imb != null) {
imb.onMultiRemoval(tmb.relayNum);
}
}
}
public void setBlockBoundsBasedOnState(IBlockAccess iba, int x, int y, int z) {
TileMultiblock tmb = CoreLib.getTileEntity(iba, x, y, z, TileMultiblock.class);
if (tmb == null) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
} else {
IMultiblock imb = CoreLib.getTileEntity(iba, tmb.relayX, tmb.relayY, tmb.relayZ, IMultiblock.class);
if (imb != null) {
AxisAlignedBB aabb = imb.getMultiBounds(tmb.relayNum);
int xa = tmb.relayX - x;
int ya = tmb.relayY - y;
int za = tmb.relayZ - z;
this.setBlockBounds(
(float)aabb.minX + (float)xa,
(float)aabb.minY + (float)ya,
(float)aabb.minZ + (float)za,
(float)aabb.maxX + (float)xa,
(float)aabb.maxY + (float)ya,
(float)aabb.maxZ + (float)za
);
}
}
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) {
TileMultiblock tmb = CoreLib.getTileEntity(world, x, y, z, TileMultiblock.class);
if (tmb == null) {
return 0.0F;
} else {
IMultiblock imb = CoreLib.getTileEntity(world, tmb.relayX, tmb.relayY, tmb.relayZ, IMultiblock.class);
return imb == null ? 0.0F : imb.getMultiBlockStrength(tmb.relayNum, player);
}
}
}

View File

@ -0,0 +1,163 @@
package com.eloraam.redpower.core;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
public class BlockMultipart extends BlockExtended {
public BlockMultipart(Material material) {
super(material);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
TileMultipart tl = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
if (tl == null) {
world.setBlockToAir(x, y, z);
} else {
tl.onBlockNeighborChange(block);
}
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (!world.isRemote) {
MovingObjectPosition mop = CoreLib.retraceBlock(world, player, x, y, z);
if (mop != null && mop.typeOfHit == MovingObjectType.BLOCK) {
TileMultipart tl = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
if (tl != null) {
tl.onHarvestPart(player, mop.subHit, willHarvest);
}
}
}
return false;
}
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xp, float yp, float zp) {
MovingObjectPosition pos = CoreLib.retraceBlock(world, player, x, y, z);
if (pos == null) {
return false;
} else if (pos.typeOfHit != MovingObjectType.BLOCK) {
return false;
} else {
TileMultipart tl = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
return tl != null && tl.onPartActivateSide(player, pos.subHit, pos.sideHit);
}
}
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) {
MovingObjectPosition pos = CoreLib.retraceBlock(world, player, x, y, z);
if (pos == null) {
return 0.0F;
} else if (pos.typeOfHit != MovingObjectType.BLOCK) {
return 0.0F;
} else {
TileMultipart tl = CoreLib.getTileEntity(player.worldObj, x, y, z, TileMultipart.class);
return tl == null ? 0.0F : tl.getPartStrength(player, pos.subHit);
}
}
public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) {
TileMultipart tl = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
if (tl != null) {
tl.breakBlock();
}
}
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB box, List list, Entity ent) {
TileMultipart tl = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
if (tl != null) {
int pm = tl.getSolidPartsMask();
while(pm > 0) {
int pt = Integer.numberOfTrailingZeros(pm);
pm &= ~(1 << pt);
tl.setPartBounds(this, pt);
super.addCollisionBoxesToList(world, x, y, z, box, list, ent);
}
}
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 start, Vec3 end) {
TileMultipart multipart = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
if (multipart == null) {
return null;
} else {
int pm = multipart.getPartsMask();
MovingObjectPosition result = null;
int cpt = -1;
double distance = 0.0;
while(pm > 0) {
int pt = Integer.numberOfTrailingZeros(pm);
pm &= ~(1 << pt);
multipart.setPartBounds(this, pt);
MovingObjectPosition mop = super.collisionRayTrace(world, x, y, z, start, end);
if (mop != null) {
double max = mop.hitVec.squareDistanceTo(start);
if (result == null || max < distance) {
distance = max;
result = mop;
cpt = pt;
}
}
}
if (result == null) {
return null;
} else {
multipart.setPartBounds(this, cpt);
result.subHit = cpt;
return result;
}
}
}
protected MovingObjectPosition traceCurrentBlock(World world, int x, int y, int z, Vec3 src, Vec3 dest) {
return super.collisionRayTrace(world, x, y, z, src, dest);
}
public void setPartBounds(World world, int x, int y, int z, int part) {
TileMultipart tl = CoreLib.getTileEntity(world, x, y, z, TileMultipart.class);
if (tl == null) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
} else {
tl.setPartBounds(this, part);
}
}
public void computeCollidingBoxes(World world, int x, int y, int z, AxisAlignedBB box, List list, TileMultipart tl) {
int pm = tl.getSolidPartsMask();
while(pm > 0) {
int pt = Integer.numberOfTrailingZeros(pm);
pm &= ~(1 << pt);
tl.setPartBounds(this, pt);
super.addCollisionBoxesToList(world, x, y, z, box, list, null);
}
}
}

View File

@ -0,0 +1,72 @@
package com.eloraam.redpower.core;
import cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry;
import cpw.mods.fml.common.registry.GameData;
import java.lang.reflect.Field;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ObjectIntIdentityMap;
import net.minecraft.util.RegistryNamespaced;
import net.minecraft.util.RegistrySimple;
public class BlockReplaceHelper {
public static void replaceBlock(Block toReplace, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemBlockClass) {
Class<?>[] classTest = new Class[4];
Exception exception = null;
try {
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
for(Field blockField : Blocks.class.getDeclaredFields()) {
if (Block.class.isAssignableFrom(blockField.getType())) {
Block block = (Block)blockField.get(null);
if (block == toReplace) {
String registryName = Block.blockRegistry.getNameForObject(block);
int id = Block.getIdFromBlock(block);
Block newBlock = (Block)blockClass.newInstance();
FMLControlledNamespacedRegistry<Block> registryBlocks = GameData.getBlockRegistry();
Field map1 = RegistrySimple.class.getDeclaredFields()[1];
map1.setAccessible(true);
((Map)map1.get(registryBlocks)).put(registryName, newBlock);
Field map2 = RegistryNamespaced.class.getDeclaredFields()[0];
map2.setAccessible(true);
((ObjectIntIdentityMap)map2.get(registryBlocks)).func_148746_a(newBlock, id);
blockField.setAccessible(true);
modifiersField.setInt(blockField, blockField.getModifiers() & -17);
blockField.set(null, newBlock);
ItemBlock itemBlock = (ItemBlock)itemBlockClass.getConstructor(Block.class).newInstance(newBlock);
FMLControlledNamespacedRegistry<Item> registryItems = GameData.getItemRegistry();
((Map)map1.get(registryItems)).put(registryName, itemBlock);
((ObjectIntIdentityMap)map2.get(registryItems)).func_148746_a(itemBlock, id);
classTest[0] = blockField.get(null).getClass();
classTest[1] = Block.blockRegistry.getObjectById(id).getClass();
classTest[2] = ((ItemBlock)Item.getItemFromBlock(newBlock)).field_150939_a.getClass();
classTest[3] = Item.getItemFromBlock(newBlock).getClass();
}
}
}
} catch (Exception var19) {
exception = var19;
}
if (classTest[0] != classTest[1] || classTest[0] != classTest[2] || classTest[0] == null || classTest[3] != itemBlockClass) {
throw new RuntimeException(
"RedPower was unable to replace block "
+ toReplace.getUnlocalizedName()
+ "! Debug info to report: "
+ classTest[0]
+ ","
+ classTest[1]
+ ","
+ classTest[2]
+ ","
+ classTest[3],
exception
);
}
}
}

View File

@ -0,0 +1,201 @@
package com.eloraam.redpower.core;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public abstract class BluePowerConductor {
private static int[] dirmap = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 11, 14, 18, 23};
int imask = 0;
double[] currents;
public double Vcap = 0.0;
public double Icap = 0.0;
public double Veff = 0.0;
int lastTick = 0;
public double It1 = 0.0;
public double Itot = 0.0;
public abstract TileEntity getParent();
public abstract double getInvCap();
public int getChargeScaled(int i) {
return 0;
}
public int getFlowScaled(int i) {
return 0;
}
public double getResistance() {
return 0.01;
}
public double getIndScale() {
return 0.07;
}
public double getCondParallel() {
return 0.5;
}
public void recache(int conm, int econm) {
int imo = 0;
for(int c2 = 0; c2 < 3; ++c2) {
if ((conm & RedPowerLib.getConDirMask(c2 * 2)) > 0) {
imo |= 1 << c2;
}
}
for(int var12 = 0; var12 < 12; ++var12) {
if ((econm & 1 << dirmap[var12]) > 0) {
imo |= 8 << var12;
}
}
if (this.imask != imo) {
double[] var11 = new double[Integer.bitCount(imo)];
int s = 0;
int d = 0;
for(int a = 0; a < 15; ++a) {
int m = 1 << a;
double v = 0.0;
if ((this.imask & m) > 0) {
v = this.currents[s++];
}
if ((imo & m) > 0) {
var11[d++] = v;
}
}
this.currents = var11;
this.imask = imo;
}
}
protected void computeVoltage() {
this.Itot = 0.5 * this.It1;
this.It1 = 0.0;
this.Vcap += 0.05 * this.Icap * this.getInvCap();
this.Icap = 0.0;
}
public double getVoltage() {
long lt = this.getParent().getWorldObj().getWorldTime();
if ((lt & 65535L) == (long)this.lastTick) {
return this.Vcap;
} else {
this.lastTick = (int)(lt & 65535L);
this.computeVoltage();
return this.Vcap;
}
}
public void applyCurrent(double Iin) {
this.getVoltage();
this.Icap += Iin;
this.It1 += Math.abs(Iin);
}
public void drawPower(double P) {
double p1 = this.Vcap * this.Vcap - 0.1 * P * this.getInvCap();
double t = p1 < 0.0 ? 0.0 : Math.sqrt(p1) - this.Vcap;
this.applyDirect(20.0 * t / this.getInvCap());
}
public double getEnergy(double vthresh) {
double d = this.getVoltage();
double tr = 0.5 * (d * d - vthresh * vthresh) / this.getInvCap();
return tr < 0.0 ? 0.0 : tr;
}
public void applyPower(double P) {
double t = Math.sqrt(this.Vcap * this.Vcap + 0.1 * P * this.getInvCap()) - this.Vcap;
this.applyDirect(20.0 * t / this.getInvCap());
}
public void applyDirect(double Iin) {
this.applyCurrent(Iin);
}
public void iterate() {
TileEntity parent = this.getParent();
World world = parent.getWorldObj();
this.getVoltage();
int dm = this.imask;
for(int s = 0; dm > 0; ++s) {
int d = Integer.numberOfTrailingZeros(dm);
dm &= ~(1 << d);
WorldCoord wc = new WorldCoord(parent);
int facing;
if (d < 3) {
facing = d * 2;
wc.step(facing);
} else {
int ibc = dirmap[d - 3];
wc.step(ibc >> 2);
facing = WorldCoord.getIndStepDir(ibc >> 2, ibc & 3);
wc.step(facing);
}
IBluePowerConnectable powerConnectable = CoreLib.getTileEntity(world, wc, IBluePowerConnectable.class);
if (powerConnectable != null) {
BluePowerConductor bpc = powerConnectable.getBlueConductor(facing ^ 1);
double r = this.getResistance() + bpc.getResistance();
double I = this.currents[s];
double V = this.Vcap - bpc.getVoltage();
this.currents[s] += (V - I * r) * this.getIndScale();
I += V * this.getCondParallel();
this.applyCurrent(-I);
bpc.applyCurrent(I);
}
}
}
public void readFromNBT(NBTTagCompound tag) {
this.imask = tag.getInteger("bpim");
int l = Integer.bitCount(this.imask);
this.currents = new double[l];
NBTTagList clist = tag.getTagList("bpil", 6);
if (clist.tagCount() == l) {
for(int i = 0; i < l; ++i) {
this.currents[i] = clist.func_150309_d(i);
}
this.Vcap = tag.getDouble("vcap");
this.Icap = tag.getDouble("icap");
this.Veff = tag.getDouble("veff");
this.It1 = tag.getDouble("it1");
this.Itot = tag.getDouble("itot");
this.lastTick = tag.getInteger("ltk");
}
}
public void writeToNBT(NBTTagCompound tag) {
tag.setInteger("bpim", this.imask);
int l = Integer.bitCount(this.imask);
NBTTagList clist = new NBTTagList();
for(int i = 0; i < l; ++i) {
NBTTagDouble val = new NBTTagDouble(this.currents[i]);
clist.appendTag(val);
}
tag.setTag("bpil", clist);
tag.setDouble("vcap", this.Vcap);
tag.setDouble("icap", this.Icap);
tag.setDouble("veff", this.Veff);
tag.setDouble("it1", this.It1);
tag.setDouble("itot", this.Itot);
tag.setInteger("ltk", this.lastTick);
}
}

View File

@ -0,0 +1,44 @@
package com.eloraam.redpower.core;
import net.minecraft.nbt.NBTTagCompound;
public abstract class BluePowerEndpoint extends BluePowerConductor {
public int Charge = 0;
public int Flow = 0;
@Override
public double getInvCap() {
return 0.25;
}
@Override
public int getChargeScaled(int i) {
return Math.min(i, i * this.Charge / 1000);
}
@Override
public int getFlowScaled(int i) {
return Integer.bitCount(this.Flow) * i / 32;
}
@Override
public void iterate() {
super.iterate();
this.Charge = (int)(this.getVoltage() * 10.0);
this.Flow = this.Flow << 1 | (this.Charge >= 600 ? 1 : 0);
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
this.Charge = tag.getShort("chg");
this.Flow = tag.getInteger("flw");
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setShort("chg", (short)this.Charge);
tag.setInteger("flw", this.Flow);
}
}

View File

@ -0,0 +1,4 @@
package com.eloraam.redpower.core;
public class BluePowerLib {
}

View File

@ -0,0 +1,49 @@
package com.eloraam.redpower.core;
import com.eloraam.redpower.RedPowerCore;
import cpw.mods.fml.common.Loader;
import java.io.File;
import java.io.InputStream;
public class Config {
private static File configDir;
private static File configFile;
private static TagFile config;
public static void loadConfig() {
config = new TagFile();
InputStream is = RedPowerCore.class.getResourceAsStream("/assets/rpcore/default.cfg");
config.readStream(is);
if (configDir == null) {
File file = Loader.instance().getConfigDir();
configDir = file;
configFile = new File(file, "redpower.cfg");
}
if (configFile.exists()) {
config.readFile(configFile);
}
config.commentFile("RedPower 2 Configuration");
}
public static void saveConfig() {
config.saveFile(configFile);
}
public static int getInt(String name) {
return config.getInt(name);
}
public static int getInt(String name, int _default) {
return config.getInt(name, _default);
}
public static String getString(String name) {
return config.getString(name);
}
public static String getString(String name, String _default) {
return config.getString(name, _default);
}
}

View File

@ -0,0 +1,49 @@
package com.eloraam.redpower.core;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
public class CoreEvents {
@SubscribeEvent
public void toolDestroyed(PlayerDestroyItemEvent ev) {
EntityPlayer player = ev.entityPlayer;
ItemStack orig = ev.original;
int ci = player.inventory.currentItem;
Item oid = orig.getItem();
int odmg = orig.getItemDamage();
ItemStack in2 = player.inventory.getStackInSlot(ci + 27);
ItemStack ist = player.inventory.getStackInSlot(ci);
if (ist != null && ist.stackSize <= 0 && in2 != null && in2.getItem() == oid && (!in2.getHasSubtypes() || in2.getItemDamage() == odmg)) {
player.inventory.setInventorySlotContents(ci, in2);
player.inventory.setInventorySlotContents(ci + 27, (ItemStack)null);
for(int i = 2; i > 0; --i) {
ist = player.inventory.getStackInSlot(ci + 9 * i);
if (ist == null) {
return;
}
if (ist.getItem() != oid) {
return;
}
if (ist.getHasSubtypes() && ist.getItemDamage() != odmg) {
return;
}
player.inventory.setInventorySlotContents(ci + 9 * i + 9, ist);
player.inventory.setInventorySlotContents(ci + 9 * i, (ItemStack)null);
}
}
}
@SubscribeEvent
public void oreRegister(OreRegisterEvent ev) {
CoreLib.registerOre(ev.Name, ev.Ore);
}
}

View File

@ -0,0 +1,337 @@
package com.eloraam.redpower.core;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.ReflectionHelper.UnableToAccessFieldException;
import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.TreeMap;
import java.util.UUID;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.oredict.OreDictionary;
public class CoreLib {
private static TreeMap<ItemStack, String> oreMap = new TreeMap<>(CoreLib::compareItemStack);
public static String[] rawColorNames = new String[]{
"white", "orange", "magenta", "lightBlue", "yellow", "lime", "pink", "gray", "silver", "cyan", "purple", "blue", "brown", "green", "red", "black"
};
public static String[] enColorNames = new String[]{
"White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink", "Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"
};
public static int[] paintColors = new int[]{
16777215, 16744448, 16711935, 7110911, 16776960, 65280, 16737408, 5460819, 9671571, 65535, 8388863, 255, 5187328, 32768, 16711680, 2039583
};
public static final Material materialRedpower = new Material(MapColor.woodColor);
public static final GameProfile REDPOWER_PROFILE = new GameProfile(UUID.fromString("d90e51a0-41af-4a37-9fd0-f2fdc15a181b"), "[RedPower]");
public static FakePlayer getRedpowerPlayer(World world, int x, int y, int z, int rotation, GameProfile profile) {
MinecraftServer server = ((WorldServer)world).func_73046_m();
FakePlayer player = FakePlayerFactory.get((WorldServer)world, profile);
double dx = (double)x + 0.5;
double dy = (double)y - 1.1;
double dz = (double)z + 0.5;
float pitch;
float yaw;
switch(rotation ^ 1) {
case 0:
pitch = 90.0F;
yaw = 0.0F;
dy -= 0.51;
break;
case 1:
pitch = -90.0F;
yaw = 0.0F;
dy += 0.51;
break;
case 2:
pitch = 0.0F;
yaw = 180.0F;
dz -= 0.51;
break;
case 3:
pitch = 0.0F;
yaw = 0.0F;
dz += 0.51;
break;
case 4:
pitch = 0.0F;
yaw = 90.0F;
dx -= 0.51;
break;
default:
pitch = 0.0F;
yaw = 270.0F;
dx += 0.51;
}
player.setLocationAndAngles(dx, dy, dz, yaw, pitch);
return player;
}
public static boolean hasBreakPermission(EntityPlayerMP player, int x, int y, int z) {
return hasEditPermission(player, x, y, z)
&& !ForgeHooks.onBlockBreakEvent(player.worldObj, player.theItemInWorldManager.getGameType(), player, x, y, z).isCanceled();
}
public static boolean hasEditPermission(EntityPlayerMP player, int x, int y, int z) {
return player.canPlayerEdit(x, y, z, player.worldObj.getBlockMetadata(x, y, z), null)
&& !MinecraftServer.getServer().isBlockProtected(player.worldObj, x, y, z, player);
}
public static void updateAllLightTypes(World world, int x, int y, int z) {
world.updateLightByType(EnumSkyBlock.Block, x, y, z);
world.updateLightByType(EnumSkyBlock.Sky, x, y, z);
}
@Deprecated
void initModule(String name) {
Class<?> cl;
try {
cl = Class.forName(name);
} catch (ClassNotFoundException var7) {
return;
}
Method mth;
try {
mth = cl.getDeclaredMethod("initialize");
} catch (NoSuchMethodException var6) {
return;
}
try {
mth.invoke(null);
} catch (InvocationTargetException | IllegalAccessException var5) {
}
}
public static <T> T getTileEntity(IBlockAccess iba, int x, int y, int z, Class<T> type) {
TileEntity tile = iba.getTileEntity(x, y, z);
return (T)(tile != null && type.isAssignableFrom(tile.getClass()) ? tile : null);
}
public static <T> T getTileEntity(IBlockAccess iba, WorldCoord wc, Class<T> type) {
TileEntity tile = iba.getTileEntity(wc.x, wc.y, wc.z);
return (T)(tile != null && type.isAssignableFrom(tile.getClass()) ? tile : null);
}
public static <T extends TileEntity> T getGuiTileEntity(World world, int x, int y, int z, Class<T> cl) {
if (!world.isRemote) {
TileEntity tr = world.getTileEntity(x, y, z);
return (T)(!cl.isInstance(tr) ? null : tr);
} else {
try {
T t = (T)cl.newInstance();
t.setWorldObj(world);
return t;
} catch (IllegalAccessException | InstantiationException var6) {
return null;
}
}
}
public static void markBlockDirty(World world, int i, int j, int k) {
if (world.blockExists(i, j, k)) {
world.getChunkFromBlockCoords(i, k).setChunkModified();
}
}
public static int compareItemStack(ItemStack a, ItemStack b) {
return Item.getIdFromItem(a.getItem()) != Item.getIdFromItem(b.getItem())
? Item.getIdFromItem(a.getItem()) - Item.getIdFromItem(b.getItem())
: (a.getItemDamage() == b.getItemDamage() ? 0 : (a.getItem().getHasSubtypes() ? a.getItemDamage() - b.getItemDamage() : 0));
}
static void registerOre(String name, ItemStack ore) {
oreMap.put(ore, name);
}
public static void readOres() {
for(String st : OreDictionary.getOreNames()) {
for(ItemStack ist : OreDictionary.getOres(st)) {
registerOre(st, ist);
}
}
}
public static String getOreClass(ItemStack ist) {
String st = (String)oreMap.get(ist);
if (st != null) {
return st;
} else {
ist = new ItemStack(ist.getItem(), 1, -1);
return (String)oreMap.get(ist);
}
}
public static boolean matchItemStackOre(ItemStack a, ItemStack b) {
String s1 = getOreClass(a);
String s2 = getOreClass(b);
return (ItemStack.areItemStacksEqual(a, b) || s1 != null && s2 != null && s1.equals(s2)) && ItemStack.areItemStackTagsEqual(a, b);
}
public static void dropItem(World world, int i, int j, int k, ItemStack ist) {
if (!world.isRemote) {
double d = 0.7;
double x = (double)world.rand.nextFloat() * d + (1.0 - d) * 0.5;
double y = (double)world.rand.nextFloat() * d + (1.0 - d) * 0.5;
double z = (double)world.rand.nextFloat() * d + (1.0 - d) * 0.5;
EntityItem item = new EntityItem(world, (double)i + x, (double)j + y, (double)k + z, ist);
item.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(item);
}
}
public static ItemStack copyStack(ItemStack ist, int n) {
return new ItemStack(ist.getItem(), n, ist.getItemDamage());
}
public static int rotToSide(int r) {
switch(r) {
case 0:
return 5;
case 1:
return 3;
case 2:
return 4;
default:
return 2;
}
}
public static int getFacing(int side) {
switch(side) {
case 0:
return 2;
case 1:
return 5;
case 2:
return 3;
case 3:
return 4;
case 4:
return 1;
case 5:
return 0;
default:
return 0;
}
}
public static MovingObjectPosition retraceBlock(World world, EntityLivingBase ent, int x, int y, int z) {
Vec3 org = Vec3.createVectorHelper(ent.posX, ent.posY + 1.62 - (double)ent.yOffset, ent.posZ);
Vec3 vec = ent.getLook(1.0F);
Vec3 end = org.addVector(vec.xCoord * 5.0, vec.yCoord * 5.0, vec.zCoord * 5.0);
Block bl = world.getBlock(x, y, z);
return bl == null ? null : bl.collisionRayTrace(world, x, y, z, org, end);
}
public static MovingObjectPosition traceBlock(EntityPlayer player) {
Vec3 org = Vec3.createVectorHelper(player.posX, player.posY + 1.62 - (double)player.yOffset, player.posZ);
Vec3 vec = player.getLook(1.0F);
Vec3 end = org.addVector(vec.xCoord * 5.0, vec.yCoord * 5.0, vec.zCoord * 5.0);
return player.worldObj.rayTraceBlocks(org, end);
}
public static void placeNoise(World world, int i, int j, int k, Block block) {
world.playSoundEffect(
(double)((float)i + 0.5F),
(double)((float)j + 0.5F),
(double)((float)k + 0.5F),
block.stepSound.func_150496_b(),
(block.stepSound.getVolume() + 1.0F) / 2.0F,
block.stepSound.getPitch() * 0.8F
);
}
public static int getBurnTime(ItemStack ist) {
return TileEntityFurnace.getItemBurnTime(ist);
}
public static double getAverageEdgeLength(AxisAlignedBB aabb) {
double d = aabb.maxX - aabb.minX;
double d1 = aabb.maxY - aabb.minY;
double d2 = aabb.maxZ - aabb.minZ;
return (d + d1 + d2) / 3.0;
}
public static void writeChat(EntityPlayer pl, String str) {
if (pl instanceof EntityPlayerMP) {
EntityPlayerMP emp = (EntityPlayerMP)pl;
emp.addChatComponentMessage(new ChatComponentText(str));
}
}
public static void updateBlock(World world, int x, int y, int z) {
if (!(world.getTileEntity(x, y, z) instanceof TileExtended)) {
world.func_147479_m(x, y, z);
}
}
public static int[] toIntArray(List<Integer> integerList) {
int[] intArray = new int[integerList.size()];
for(int i = 0; i < integerList.size(); ++i) {
intArray[i] = integerList.get(i);
}
return intArray;
}
public static <T, E> void setFinalValue(Class<? super T> classToAccess, T instance, E value, String... fieldNames) {
try {
findField(classToAccess, fieldNames).set(instance, value);
} catch (Exception var5) {
throw new UnableToAccessFieldException(fieldNames, var5);
}
}
public static Field findField(Class<?> clazz, String... fieldNames) {
Exception failed = null;
for(String fieldName : fieldNames) {
try {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & -17);
return field;
} catch (Exception var9) {
failed = var9;
}
}
throw new UnableToFindFieldException(fieldNames, failed);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,346 @@
package com.eloraam.redpower.core;
import com.eloraam.redpower.base.ItemHandsaw;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
public class CoverRecipe implements IRecipe {
private static ItemStack newCover(int num, int type, int mat) {
return new ItemStack(CoverLib.blockCoverPlate, num, type << 8 | mat);
}
private ItemStack getSawRecipe(InventoryCrafting inv, ItemStack saw, int sawpos, ItemStack mat, int matpos) {
int sp1 = sawpos & 15;
int sp2 = sawpos >> 4;
int mp1 = matpos & 15;
int mp2 = matpos >> 4;
int dmg = -1;
int mn1;
if (mat.getItem() == Item.getItemFromBlock(CoverLib.blockCoverPlate)) {
dmg = mat.getItemDamage();
mn1 = dmg & 0xFF;
dmg >>= 8;
} else {
Integer ihs = CoverLib.getMaterial(mat);
if (ihs == null) {
return null;
}
mn1 = ihs;
}
ItemHandsaw ihs1 = (ItemHandsaw)saw.getItem();
if (ihs1.getSharpness() < CoverLib.getHardness(mn1)) {
return null;
} else if (sp1 != mp1 || sp2 != mp2 + 1 && sp2 != mp2 - 1) {
if (sp2 == mp2 && (sp1 == mp1 + 1 || sp1 == mp1 - 1)) {
switch(dmg) {
case 0:
return newCover(2, 21, mn1);
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 18:
case 19:
case 20:
case 24:
case 25:
case 26:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
default:
return null;
case 16:
return newCover(2, 22, mn1);
case 17:
return newCover(2, 23, mn1);
case 21:
return newCover(2, 18, mn1);
case 22:
return newCover(2, 19, mn1);
case 23:
return newCover(2, 20, mn1);
case 27:
return newCover(2, 39, mn1);
case 28:
return newCover(2, 40, mn1);
case 29:
return newCover(2, 41, mn1);
case 30:
return newCover(2, 42, mn1);
case 39:
return newCover(2, 35, mn1);
case 40:
return newCover(2, 36, mn1);
case 41:
return newCover(2, 37, mn1);
case 42:
return newCover(2, 38, mn1);
}
} else {
return null;
}
} else {
switch(dmg) {
case -1:
return newCover(2, 17, mn1);
case 16:
return newCover(2, 0, mn1);
case 17:
return newCover(2, 16, mn1);
case 25:
return newCover(2, 24, mn1);
case 26:
return newCover(2, 25, mn1);
case 29:
return newCover(2, 27, mn1);
case 33:
return newCover(2, 31, mn1);
default:
return null;
}
}
}
private ItemStack getColumnRecipe(ItemStack mat) {
if (mat.getItem() != Item.getItemFromBlock(CoverLib.blockCoverPlate)) {
return null;
} else {
int dmg = mat.getItemDamage();
int mn = dmg & 0xFF;
dmg >>= 8;
switch(dmg) {
case 22:
return newCover(1, 43, mn);
case 23:
return newCover(1, 44, mn);
case 41:
return newCover(1, 45, mn);
case 43:
return newCover(1, 22, mn);
case 44:
return newCover(1, 23, mn);
case 45:
return newCover(1, 41, mn);
default:
return null;
}
}
}
private ItemStack getMergeRecipe(int mn, int tth, int ic) {
int mc = mn >> 20;
mn &= 255;
switch(mc) {
case 0:
switch(tth) {
case 2:
return newCover(1, 16, mn);
case 3:
return newCover(1, 27, mn);
case 4:
return newCover(1, 17, mn);
case 5:
return newCover(1, 28, mn);
case 6:
return newCover(1, 29, mn);
case 7:
return newCover(1, 30, mn);
case 8:
return CoverLib.getItemStack(mn);
default:
return null;
}
case 1:
switch(tth) {
case 2:
return newCover(1, 25, mn);
case 3:
return newCover(1, 31, mn);
case 4:
return newCover(1, 26, mn);
case 5:
return newCover(1, 32, mn);
case 6:
return newCover(1, 33, mn);
case 7:
return newCover(1, 34, mn);
case 8:
return CoverLib.getItemStack(mn);
default:
return null;
}
case 16:
switch(tth) {
case 2:
return newCover(1, 0, mn);
case 4:
return newCover(1, 16, mn);
case 8:
return newCover(1, 17, mn);
case 16:
return CoverLib.getItemStack(mn);
default:
return null;
}
case 32:
if (ic == 2) {
switch(tth) {
case 2:
return newCover(1, 21, mn);
case 4:
return newCover(1, 22, mn);
case 8:
return newCover(1, 23, mn);
}
} else {
switch(tth) {
case 4:
return newCover(1, 0, mn);
case 8:
return newCover(1, 16, mn);
case 16:
return newCover(1, 17, mn);
case 32:
return CoverLib.getItemStack(mn);
}
}
default:
return null;
}
}
private ItemStack getHollowRecipe(int mn) {
int mc = mn >> 8 & 0xFF;
mn &= 255;
switch(mc) {
case 0:
return newCover(8, 24, mn);
case 16:
return newCover(8, 25, mn);
case 17:
return newCover(8, 26, mn);
case 27:
return newCover(8, 31, mn);
case 28:
return newCover(8, 32, mn);
case 29:
return newCover(8, 33, mn);
case 30:
return newCover(8, 34, mn);
default:
return null;
}
}
private int getMicroClass(ItemStack ist) {
if (ist.getItem() != Item.getItemFromBlock(CoverLib.blockCoverPlate)) {
return -1;
} else {
int dmg = ist.getItemDamage();
return CoverLib.damageToCoverData(dmg);
}
}
private ItemStack findResult(InventoryCrafting inv) {
ItemStack saw = null;
ItemStack mat = null;
boolean bad = false;
boolean allmicro = true;
boolean strict = true;
int sp = 0;
int mp = 0;
int mn = -1;
int tth = 0;
int ic = 0;
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 3; ++j) {
ItemStack ist = inv.getStackInRowAndColumn(i, j);
if (ist != null) {
if (ist.getItem() instanceof ItemHandsaw) {
if (saw != null) {
bad = true;
} else {
saw = ist;
sp = i + j * 16;
}
} else if (mat == null) {
mat = ist;
mp = i + j * 16;
mn = this.getMicroClass(ist);
if (mn >= 0) {
tth += mn >> 16 & 15;
} else {
allmicro = false;
}
ic = 1;
} else {
bad = true;
if (allmicro) {
int t = this.getMicroClass(ist);
if (((t ^ mn) & -1048321) != 0) {
allmicro = false;
} else {
if (t != mn) {
strict = false;
}
tth += t >> 16 & 15;
++ic;
}
}
}
}
}
}
if (saw != null && mat != null && !bad) {
return this.getSawRecipe(inv, saw, sp, mat, mp);
} else if (saw == null && mat != null && !bad) {
return this.getColumnRecipe(mat);
} else if (!allmicro || !bad || saw != null) {
return null;
} else {
return ic == 8 && strict && inv.getStackInRowAndColumn(1, 1) == null && mn >> 20 == 0 ? this.getHollowRecipe(mn) : this.getMergeRecipe(mn, tth, ic);
}
}
public boolean matches(InventoryCrafting inv, World world) {
return this.findResult(inv) != null;
}
public int getRecipeSize() {
return 9;
}
public ItemStack getCraftingResult(InventoryCrafting inv) {
return this.findResult(inv).copy();
}
public ItemStack getRecipeOutput() {
return new ItemStack(CoverLib.blockCoverPlate, 1, 0);
}
}

View File

@ -0,0 +1,546 @@
package com.eloraam.redpower.core;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
@SideOnly(Side.CLIENT)
public class CoverRenderer {
private float cx1;
private float cx2;
private float cy1;
private float cy2;
private float cz1;
private float cz2;
private float[] x1 = new float[4];
private float[] x2 = new float[4];
private float[] y1 = new float[4];
private float[] y2 = new float[4];
private float[] z1 = new float[4];
private float[] z2 = new float[4];
private short[] covs;
private int covmask;
private int covmaskt;
private int covmaskh;
private int covmasko;
public static IIcon[][] coverIcons = new IIcon[256][];
protected RenderContext context;
public CoverRenderer(RenderContext ctx) {
this.context = ctx;
}
public void start() {
this.cx1 = 0.0F;
this.cx2 = 1.0F;
this.cy1 = 0.0F;
this.cy2 = 1.0F;
this.cz1 = 0.0F;
this.cz2 = 1.0F;
}
public void startShrink(float sh) {
this.cx1 = sh;
this.cx2 = 1.0F - sh;
this.cy1 = sh;
this.cy2 = 1.0F - sh;
this.cz1 = sh;
this.cz2 = 1.0F - sh;
}
public void sizeHollow(int part, int s) {
switch(part) {
case 0:
case 1:
if (s == 0) {
this.context.boxSize2.x = 0.25;
}
if (s == 1) {
this.context.boxSize1.x = 0.75;
}
if (s > 1) {
this.context.boxSize1.x = 0.25;
this.context.boxSize2.x = 0.75;
}
if (s == 2) {
this.context.boxSize2.z = 0.25;
}
if (s == 3) {
this.context.boxSize1.z = 0.75;
}
break;
case 2:
case 3:
if (s == 0) {
this.context.boxSize2.x = 0.25;
}
if (s == 1) {
this.context.boxSize1.x = 0.75;
}
if (s > 1) {
this.context.boxSize1.x = 0.25;
this.context.boxSize2.x = 0.75;
}
if (s == 2) {
this.context.boxSize2.y = 0.25;
}
if (s == 3) {
this.context.boxSize1.y = 0.75;
}
break;
default:
if (s == 0) {
this.context.boxSize2.z = 0.25;
}
if (s == 1) {
this.context.boxSize1.z = 0.75;
}
if (s > 1) {
this.context.boxSize1.z = 0.25;
this.context.boxSize2.z = 0.75;
}
if (s == 2) {
this.context.boxSize2.y = 0.25;
}
if (s == 3) {
this.context.boxSize1.y = 0.75;
}
}
}
public int innerFace(int part, int s) {
int m;
switch(part) {
case 0:
case 1:
m = 67637280;
break;
case 2:
case 3:
m = 16912416;
break;
default:
m = 16909320;
}
return m >> s * 8;
}
public boolean sizeColumnSpoke(int part, boolean n1, float f) {
part = part - 26 + (n1 ? 3 : 0);
switch(part) {
case 0:
this.context.boxSize2.y = 0.5 - (double)f;
return 0.5 - (double)f > (double)this.cy1;
case 1:
this.context.boxSize2.z = 0.5 - (double)f;
return 0.5 - (double)f > (double)this.cz1;
case 2:
this.context.boxSize2.x = 0.5 - (double)f;
return 0.5 - (double)f > (double)this.cx1;
case 3:
this.context.boxSize2.y = (double)this.cy2;
this.context.boxSize1.y = 0.5 + (double)f;
return 0.5 + (double)f < (double)this.cy2;
case 4:
this.context.boxSize2.z = (double)this.cz2;
this.context.boxSize1.z = 0.5 + (double)f;
return 0.5 + (double)f < (double)this.cz2;
case 5:
this.context.boxSize2.x = (double)this.cx2;
this.context.boxSize1.x = 0.5 + (double)f;
return 0.5 + (double)f < (double)this.cx2;
default:
return false;
}
}
public void setSize(int part, float th) {
switch(part) {
case 0:
this.context.setSize((double)this.cx1, 0.0, (double)this.cz1, (double)this.cx2, (double)th, (double)this.cz2);
this.cy1 = th;
break;
case 1:
this.context.setSize((double)this.cx1, (double)(1.0F - th), (double)this.cz1, (double)this.cx2, 1.0, (double)this.cz2);
this.cy2 = 1.0F - th;
break;
case 2:
this.context.setSize((double)this.cx1, (double)this.cy1, 0.0, (double)this.cx2, (double)this.cy2, (double)th);
this.cz1 = th;
break;
case 3:
this.context.setSize((double)this.cx1, (double)this.cy1, (double)(1.0F - th), (double)this.cx2, (double)this.cy2, 1.0);
this.cz2 = 1.0F - th;
break;
case 4:
this.context.setSize(0.0, (double)this.cy1, (double)this.cz1, (double)th, (double)this.cy2, (double)this.cz2);
this.cx1 = th;
break;
case 5:
this.context.setSize((double)(1.0F - th), (double)this.cy1, (double)this.cz1, 1.0, (double)this.cy2, (double)this.cz2);
this.cx2 = 1.0F - th;
break;
case 6:
this.context.setSize((double)this.cx1, (double)this.cy1, (double)this.cz1, (double)th, (double)th, (double)th);
this.x1[0] = th;
this.y1[0] = th;
this.z1[0] = th;
break;
case 7:
this.context.setSize((double)this.cx1, (double)this.cy1, (double)(1.0F - th), (double)th, (double)th, (double)this.cz2);
this.x1[1] = th;
this.y1[1] = th;
this.z2[0] = 1.0F - th;
break;
case 8:
this.context.setSize((double)(1.0F - th), (double)this.cy1, (double)this.cz1, (double)this.cx2, (double)th, (double)th);
this.x2[0] = 1.0F - th;
this.y1[2] = th;
this.z1[1] = th;
break;
case 9:
this.context.setSize((double)(1.0F - th), (double)this.cy1, (double)(1.0F - th), (double)this.cx2, (double)th, (double)this.cz2);
this.x2[1] = 1.0F - th;
this.y1[3] = th;
this.z2[1] = 1.0F - th;
break;
case 10:
this.context.setSize((double)this.cx1, (double)(1.0F - th), (double)this.cz1, (double)th, (double)this.cy2, (double)th);
this.x1[2] = th;
this.y2[0] = 1.0F - th;
this.z1[2] = th;
break;
case 11:
this.context.setSize((double)this.cx1, (double)(1.0F - th), (double)(1.0F - th), (double)th, (double)this.cy2, (double)this.cz2);
this.x1[3] = th;
this.y2[1] = 1.0F - th;
this.z2[2] = 1.0F - th;
break;
case 12:
this.context.setSize((double)(1.0F - th), (double)(1.0F - th), (double)this.cz1, (double)this.cx2, (double)this.cy2, (double)th);
this.x2[2] = 1.0F - th;
this.y2[2] = 1.0F - th;
this.z1[3] = th;
break;
case 13:
this.context.setSize((double)(1.0F - th), (double)(1.0F - th), (double)(1.0F - th), (double)this.cx2, (double)this.cy2, (double)this.cz2);
this.x2[3] = 1.0F - th;
this.y2[3] = 1.0F - th;
this.z2[3] = 1.0F - th;
break;
case 14:
this.context.setSize((double)this.x1[0], (double)this.cy1, (double)this.cz1, (double)this.x2[0], (double)th, (double)th);
this.z1[0] = Math.max(this.z1[0], th);
this.z1[1] = Math.max(this.z1[1], th);
this.y1[0] = Math.max(this.y1[0], th);
this.y1[2] = Math.max(this.y1[2], th);
break;
case 15:
this.context.setSize((double)this.x1[1], (double)this.cy1, (double)(1.0F - th), (double)this.x2[1], (double)th, (double)this.cz2);
this.z2[0] = Math.min(this.z2[0], 1.0F - th);
this.z2[1] = Math.min(this.z2[1], 1.0F - th);
this.y1[1] = Math.max(this.y1[1], th);
this.y1[3] = Math.max(this.y1[3], th);
break;
case 16:
this.context.setSize((double)this.cx1, (double)this.cy1, (double)this.z1[0], (double)th, (double)th, (double)this.z2[0]);
this.x1[0] = Math.max(this.x1[0], th);
this.x1[1] = Math.max(this.x1[1], th);
this.y1[0] = Math.max(this.y1[0], th);
this.y1[1] = Math.max(this.y1[1], th);
break;
case 17:
this.context.setSize((double)(1.0F - th), (double)this.cy1, (double)this.z1[1], (double)this.cx2, (double)th, (double)this.z2[1]);
this.x2[0] = Math.min(this.x2[0], 1.0F - th);
this.x2[1] = Math.min(this.x2[1], 1.0F - th);
this.y1[2] = Math.max(this.y1[2], th);
this.y1[3] = Math.max(this.y1[3], th);
break;
case 18:
this.context.setSize((double)this.cx1, (double)this.y1[0], (double)this.cz1, (double)th, (double)this.y2[0], (double)th);
this.x1[0] = Math.max(this.x1[0], th);
this.x1[2] = Math.max(this.x1[2], th);
this.z1[0] = Math.max(this.z1[0], th);
this.z1[2] = Math.max(this.z1[2], th);
break;
case 19:
this.context.setSize((double)this.cx1, (double)this.y1[1], (double)(1.0F - th), (double)th, (double)this.y2[1], (double)this.cz2);
this.x1[1] = Math.max(this.x1[1], th);
this.x1[3] = Math.max(this.x1[3], th);
this.z2[0] = Math.min(this.z2[0], 1.0F - th);
this.z2[2] = Math.min(this.z2[2], 1.0F - th);
break;
case 20:
this.context.setSize((double)(1.0F - th), (double)this.y1[2], (double)this.cz1, (double)this.cx2, (double)this.y2[2], (double)th);
this.x2[0] = Math.min(this.x2[0], 1.0F - th);
this.x2[2] = Math.min(this.x2[2], 1.0F - th);
this.z1[1] = Math.max(this.z1[1], th);
this.z1[3] = Math.max(this.z1[3], th);
break;
case 21:
this.context.setSize((double)(1.0F - th), (double)this.y1[3], (double)(1.0F - th), (double)this.cx2, (double)this.y2[3], (double)this.cz2);
this.x2[1] = Math.min(this.x2[1], 1.0F - th);
this.x2[3] = Math.min(this.x2[3], 1.0F - th);
this.z2[1] = Math.min(this.z2[1], 1.0F - th);
this.z2[3] = Math.min(this.z2[3], 1.0F - th);
break;
case 22:
this.context.setSize((double)this.x1[2], (double)(1.0F - th), (double)this.cz1, (double)this.x2[2], (double)this.cy2, (double)th);
this.z1[2] = Math.max(this.z1[2], th);
this.z1[3] = Math.max(this.z1[3], th);
this.y2[0] = Math.min(this.y2[0], 1.0F - th);
this.y2[2] = Math.min(this.y2[2], 1.0F - th);
break;
case 23:
this.context.setSize((double)this.x1[3], (double)(1.0F - th), (double)(1.0F - th), (double)this.x2[3], (double)this.cy2, (double)this.cz2);
this.z2[2] = Math.max(this.z2[2], 1.0F - th);
this.z2[3] = Math.max(this.z2[3], 1.0F - th);
this.y2[1] = Math.min(this.y2[1], 1.0F - th);
this.y2[3] = Math.min(this.y2[3], 1.0F - th);
break;
case 24:
this.context.setSize((double)this.cx1, (double)(1.0F - th), (double)this.z1[2], (double)th, (double)this.cy2, (double)this.z2[2]);
this.x1[2] = Math.max(this.x1[2], th);
this.x1[3] = Math.max(this.x1[3], th);
this.y2[0] = Math.min(this.y2[0], 1.0F - th);
this.y2[1] = Math.min(this.y2[1], 1.0F - th);
break;
case 25:
this.context.setSize((double)(1.0F - th), (double)(1.0F - th), (double)this.z1[3], (double)this.cx2, (double)this.cy2, (double)this.z2[3]);
this.x2[2] = Math.min(this.x2[2], 1.0F - th);
this.x2[3] = Math.min(this.x2[3], 1.0F - th);
this.y2[2] = Math.min(this.y2[2], 1.0F - th);
this.y2[3] = Math.min(this.y2[3], 1.0F - th);
break;
case 26:
this.context.setSize(0.5 - (double)th, (double)this.cy1, 0.5 - (double)th, 0.5 + (double)th, (double)this.cy2, 0.5 + (double)th);
break;
case 27:
this.context.setSize(0.5 - (double)th, 0.5 - (double)th, (double)this.cz1, 0.5 + (double)th, 0.5 + (double)th, (double)this.cz2);
break;
case 28:
this.context.setSize((double)this.cx1, 0.5 - (double)th, 0.5 - (double)th, (double)this.cx2, 0.5 + (double)th, 0.5 + (double)th);
}
}
void setupCorners() {
for(int i = 0; i < 4; ++i) {
this.x1[i] = this.cx1;
this.y1[i] = this.cy1;
this.z1[i] = this.cz1;
this.x2[i] = this.cx2;
this.y2[i] = this.cy2;
this.z2[i] = this.cz2;
}
}
public void initMasks(int uc, short[] cv) {
this.covmask = uc;
this.covs = cv;
this.covmaskt = 0;
this.covmaskh = 0;
this.covmasko = 0;
for(int i = 0; i < 6; ++i) {
if ((uc & 1 << i) != 0) {
if (CoverLib.isTransparent(this.covs[i] & 255)) {
this.covmaskt |= 1 << i;
}
if (this.covs[i] >> 8 > 2) {
this.covmaskh |= 1 << i;
}
}
}
this.covmasko = this.covmask & ~this.covmaskt & ~this.covmaskh;
}
public void render(int uc, short[] cv) {
this.initMasks(uc, cv);
this.start();
this.renderShell();
if ((uc & -64) != 0) {
this.renderOthers();
}
}
public void renderShrink(int uc, short[] cv, float sh) {
this.initMasks(uc, cv);
this.startShrink(sh);
this.renderShell();
if ((uc & -64) != 0) {
this.renderOthers();
}
}
public void setIcon(int cn) {
this.context.setIcon(coverIcons[cn]);
}
public void setIcon(int c1, int c2, int c3, int c4, int c5, int c6) {
this.context.setIcon(coverIcons[c1][0], coverIcons[c2][1], coverIcons[c3][2], coverIcons[c4][3], coverIcons[c5][4], coverIcons[c6][5]);
}
public void renderShell() {
this.context.setOrientation(0, 0);
this.context.setLocalLights(0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F);
if (this.covmasko > 0) {
this.context.setSize(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
this.setIcon(this.covs[0] & 255, this.covs[1] & 255, this.covs[2] & 255, this.covs[3] & 255, this.covs[4] & 255, this.covs[5] & 255);
this.context.setTexFlags(55);
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(this.covmasko);
}
int rsf = (this.covmasko | this.covmaskh) & ~this.covmaskt;
if (rsf > 0) {
for(int i = 0; i < 6; ++i) {
if ((rsf & 1 << i) != 0) {
this.setIcon(this.covs[i] & 255);
int cn = this.covs[i] >> 8;
int vf = 1 << (i ^ 1) | 63 ^ this.covmasko;
if (cn >= 3 && cn <= 5 || cn >= 10 && cn <= 13) {
for(int j = 0; j < 4; ++j) {
this.setSize(i, CoverLib.getThickness(i, this.covs[i]));
this.sizeHollow(i, j);
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(vf | this.innerFace(i, j));
}
} else {
this.setSize(i, CoverLib.getThickness(i, this.covs[i]));
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(vf);
}
}
}
}
if (this.covmaskt > 0) {
for(int i = 0; i < 6; ++i) {
if ((this.covmaskt & 1 << i) != 0) {
this.setIcon(this.covs[i] & 255);
int cn = this.covs[i] >> 8;
int vf = 1 << (i ^ 1) | 63 ^ this.covmasko;
if (cn >= 3 && cn <= 5 || cn >= 10 && cn <= 13) {
for(int j = 0; j < 4; ++j) {
this.setSize(i, CoverLib.getThickness(i, this.covs[i]));
this.sizeHollow(i, j);
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(vf | this.innerFace(i, j));
}
} else {
this.setSize(i, CoverLib.getThickness(i, this.covs[i]));
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(vf);
}
}
}
}
}
public void renderOthers() {
float cth = 0.0F;
int colc = 0;
int coln = 0;
for(int j = 26; j < 29; ++j) {
if ((this.covmasko & 1 << j) != 0) {
++colc;
float i = CoverLib.getThickness(j, this.covs[j]);
if (i > cth) {
coln = j;
cth = i;
}
}
}
if (colc > 1) {
this.setIcon(this.covs[coln] & 255);
this.context.setSize(0.5 - (double)cth, 0.5 - (double)cth, 0.5 - (double)cth, 0.5 + (double)cth, 0.5 + (double)cth, 0.5 + (double)cth);
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(63);
for(int var61 = 26; var61 < 29; ++var61) {
if ((this.covmasko & 1 << var61) != 0) {
this.setIcon(this.covs[var61] & 255);
this.setSize(var61, CoverLib.getThickness(var61, this.covs[var61]));
if (this.sizeColumnSpoke(var61, false, cth)) {
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(63);
}
if (this.sizeColumnSpoke(var61, true, cth)) {
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(63);
}
}
}
} else if (colc == 1) {
this.setIcon(this.covs[coln] & 255);
this.setSize(coln, CoverLib.getThickness(coln, this.covs[coln]));
this.context.calcBoundsGlobal();
this.context.renderGlobFaces(63 ^ 3 << coln - 25 & this.covmasko);
}
this.setupCorners();
for(int var7 = 6; var7 < 14; ++var7) {
if ((this.covmasko & 1 << var7) != 0) {
this.setSize(var7, CoverLib.getThickness(var7, this.covs[var7]));
this.context.calcBoundsGlobal();
this.setIcon(this.covs[var7] & 255);
this.context.renderGlobFaces(63);
}
}
for(int var8 = 6; var8 >= 0; --var8) {
for(int var6 = 14; var6 < 26; ++var6) {
if ((this.covmasko & 1 << var6) != 0 && this.covs[var6] >> 8 == var8) {
this.setSize(var6, CoverLib.getThickness(var6, this.covs[var6]));
this.context.calcBoundsGlobal();
this.setIcon(this.covs[var6] & 255);
this.context.renderGlobFaces(63);
}
}
}
}
@SideOnly(Side.CLIENT)
public static void reInitIcons() {
for(int i = 0; i < CoverLib.materials.length; ++i) {
ItemStack is = CoverLib.materials[i];
if (is != null) {
Block b = Block.getBlockFromItem(is.getItem());
if (b != null) {
for(int side = 0; side < 6; ++side) {
coverIcons[i][side] = b.getIcon(side, is.getItemDamage());
}
}
}
}
}
}

View File

@ -0,0 +1,138 @@
package com.eloraam.redpower.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
public class CraftLib {
public static List<List<Object>> alloyRecipes = new ArrayList();
public static HashSet damageOnCraft = new HashSet();
public static HashMap damageContainer = new HashMap();
public static void addAlloyResult(ItemStack output, Object... input) {
alloyRecipes.add(Arrays.asList(input, output));
}
public static void addOreRecipe(ItemStack output, Object... input) {
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, new Object[]{Boolean.TRUE, input}));
}
public static void addShapelessOreRecipe(ItemStack output, Object... input) {
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, input));
}
public static boolean isOreClass(ItemStack ist, String ore) {
for(ItemStack stack : OreDictionary.getOres(ore)) {
if (stack.isItemEqual(ist)) {
return true;
}
}
return false;
}
public static ItemStack getAlloyResult(ItemStack[] input, int start, int end, boolean take) {
label134:
for(List<Object> l : alloyRecipes) {
Object[] ob = l.toArray();
Object[] ipt = (Object[]) ob[0];
for(Object ingredient : ipt) {
if (ingredient instanceof ItemStack) {
ItemStack inputStack = (ItemStack)ingredient;
int rc = inputStack.stackSize;
for(int i = start; i < end; ++i) {
if (input[i] != null) {
if (input[i].isItemEqual(inputStack)) {
rc -= input[i].stackSize;
}
if (rc <= 0) {
break;
}
}
}
if (rc > 0) {
continue label134;
}
} else if (ingredient instanceof OreStack) {
OreStack inputStack = (OreStack)ingredient;
int rc = inputStack.quantity;
for(int i = start; i < end; ++i) {
if (input[i] != null) {
if (isOreClass(input[i], inputStack.material)) {
rc -= input[i].stackSize;
}
if (rc <= 0) {
break;
}
}
}
if (rc > 0) {
continue label134;
}
}
}
if (take) {
for(Object ingredient : ipt) {
if (ingredient instanceof ItemStack) {
ItemStack inputStack = (ItemStack)ingredient;
int rc = inputStack.stackSize;
for(int i = start; i < end; ++i) {
if (input[i] != null && input[i].isItemEqual(inputStack)) {
rc -= input[i].stackSize;
if (rc < 0) {
input[i].stackSize = -rc;
} else if (input[i].getItem().hasContainerItem()) {
input[i] = new ItemStack(input[i].getItem().getContainerItem());
} else {
input[i] = null;
}
if (rc <= 0) {
break;
}
}
}
} else if (ingredient instanceof OreStack) {
OreStack inputStack = (OreStack)ingredient;
int rc = inputStack.quantity;
for(int i = start; i < end; ++i) {
if (input[i] != null && isOreClass(input[i], inputStack.material)) {
rc -= input[i].stackSize;
if (rc < 0) {
input[i].stackSize = -rc;
} else {
input[i] = null;
}
if (rc <= 0) {
break;
}
}
}
}
}
}
return (ItemStack)ob[1];
}
return null;
}
}

View File

@ -0,0 +1,36 @@
package com.eloraam.redpower.core;
import com.eloraam.redpower.RedPowerBase;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class CreativeExtraTabs {
public static CreativeTabs tabWires = new CreativeTabs(CreativeTabs.getNextID(), "RPWires") {
public ItemStack getIconItemStack() {
return new ItemStack(RedPowerBase.blockMicro, 1, 768);
}
public Item getTabIconItem() {
return null;
}
};
public static CreativeTabs tabMicros = new CreativeTabs(CreativeTabs.getNextID(), "RPMicroblocks") {
public ItemStack getIconItemStack() {
return new ItemStack(RedPowerBase.blockMicro, 1, 23);
}
public Item getTabIconItem() {
return null;
}
};
public static CreativeTabs tabMachine = new CreativeTabs(CreativeTabs.getNextID(), "RPMachines") {
public ItemStack getIconItemStack() {
return new ItemStack(RedPowerBase.blockAppliance, 1, 3);
}
public Item getTabIconItem() {
return null;
}
};
}

View File

@ -0,0 +1,27 @@
package com.eloraam.redpower.core;
import com.eloraam.redpower.RedPowerCore;
import java.io.File;
import net.minecraft.world.World;
public class DiskLib {
public static File getSaveDir(World world) {
File tr = new File(RedPowerCore.getSaveDir(world), "redpower");
tr.mkdirs();
return tr;
}
public static String generateSerialNumber(World world) {
StringBuilder tr = new StringBuilder();
for(int i = 0; i < 16; ++i) {
tr.append(String.format("%01x", world.rand.nextInt(16)));
}
return tr.toString();
}
public static File getDiskFile(File dir, String serno) {
return new File(dir, String.format("disk_%s.img", serno));
}
}

View File

@ -0,0 +1,73 @@
package com.eloraam.redpower.core;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class EntityCustomDiggingFX extends EntityFX {
public EntityCustomDiggingFX(World world, double x, double y, double z, double mx, double my, double mz, IIcon icon, int color) {
super(world, x, y, z, mx, my, mz);
this.setParticleIcon(icon);
super.particleGravity = 1.0F;
super.particleRed = super.particleGreen = super.particleBlue = 0.6F;
super.particleScale /= 2.0F;
super.particleRed *= (float)(color >> 16 & 0xFF) / 255.0F;
super.particleGreen *= (float)(color >> 8 & 0xFF) / 255.0F;
super.particleBlue *= (float)(color & 0xFF) / 255.0F;
}
public int getFXLayer() {
return 1;
}
public void renderParticle(Tessellator tess, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) {
float f6 = ((float)super.particleTextureIndexX + super.particleTextureJitterX / 4.0F) / 16.0F;
float f7 = f6 + 0.015609375F;
float f8 = ((float)super.particleTextureIndexY + super.particleTextureJitterY / 4.0F) / 16.0F;
float f9 = f8 + 0.015609375F;
float f10 = 0.1F * super.particleScale;
if (super.particleIcon != null) {
f6 = super.particleIcon.getInterpolatedU((double)(super.particleTextureJitterX / 4.0F * 16.0F));
f7 = super.particleIcon.getInterpolatedU((double)((super.particleTextureJitterX + 1.0F) / 4.0F * 16.0F));
f8 = super.particleIcon.getInterpolatedV((double)(super.particleTextureJitterY / 4.0F * 16.0F));
f9 = super.particleIcon.getInterpolatedV((double)((super.particleTextureJitterY + 1.0F) / 4.0F * 16.0F));
}
float f11 = (float)(super.prevPosX + (super.posX - super.prevPosX) * (double)p_70539_2_ - EntityFX.interpPosX);
float f12 = (float)(super.prevPosY + (super.posY - super.prevPosY) * (double)p_70539_2_ - EntityFX.interpPosY);
float f13 = (float)(super.prevPosZ + (super.posZ - super.prevPosZ) * (double)p_70539_2_ - EntityFX.interpPosZ);
tess.setColorOpaque_F(super.particleRed, super.particleGreen, super.particleBlue);
tess.addVertexWithUV(
(double)(f11 - p_70539_3_ * f10 - p_70539_6_ * f10),
(double)(f12 - p_70539_4_ * f10),
(double)(f13 - p_70539_5_ * f10 - p_70539_7_ * f10),
(double)f6,
(double)f9
);
tess.addVertexWithUV(
(double)(f11 - p_70539_3_ * f10 + p_70539_6_ * f10),
(double)(f12 + p_70539_4_ * f10),
(double)(f13 - p_70539_5_ * f10 + p_70539_7_ * f10),
(double)f6,
(double)f8
);
tess.addVertexWithUV(
(double)(f11 + p_70539_3_ * f10 + p_70539_6_ * f10),
(double)(f12 + p_70539_4_ * f10),
(double)(f13 + p_70539_5_ * f10 + p_70539_7_ * f10),
(double)f7,
(double)f8
);
tess.addVertexWithUV(
(double)(f11 + p_70539_3_ * f10 - p_70539_6_ * f10),
(double)(f12 - p_70539_4_ * f10),
(double)(f13 + p_70539_5_ * f10 - p_70539_7_ * f10),
(double)f7,
(double)f9
);
}
}

View File

@ -0,0 +1,32 @@
package com.eloraam.redpower.core;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
public class EnvironLib {
public static double getWindSpeed(World world, WorldCoord wc) {
if (world.provider.isHellWorld) {
return 0.5;
} else {
double nv = FractalLib.noise1D(2576710L, (double)world.getWorldTime() * 1.0E-4, 0.6F, 5);
nv = Math.max(0.0, 1.6 * (nv - 0.5) + 0.5);
if (world.getWorldInfo().getTerrainType() != WorldType.FLAT) {
nv *= Math.sqrt((double)wc.y) / 16.0;
}
BiomeGenBase bgb = world.getBiomeGenForCoords(wc.x, wc.z);
if (bgb.canSpawnLightningBolt()) {
if (world.isThundering()) {
return 4.0 * nv;
}
if (world.isRaining()) {
return 0.5 + 0.5 * nv;
}
}
return nv;
}
}
}

View File

@ -0,0 +1,12 @@
package com.eloraam.redpower.core;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.util.FakePlayer;
public class FakePlayerNetHandler extends NetHandlerPlayServer {
public FakePlayerNetHandler(MinecraftServer server, FakePlayer player) {
super(server, new NetworkManager(false), player);
}
}

View File

@ -0,0 +1,78 @@
package com.eloraam.redpower.core;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public abstract class FluidBuffer {
public Fluid Type;
public int Level;
public int Delta;
private int lastTick;
public abstract TileEntity getParent();
public abstract void onChange();
public int getMaxLevel() {
return 1000;
}
public int getLevel() {
long lt = this.getParent().getWorldObj().getWorldTime();
if ((lt & 65535L) == (long)this.lastTick) {
return this.Level;
} else {
this.lastTick = (int)(lt & 65535L);
this.Level += this.Delta;
this.Delta = 0;
if (this.Level == 0) {
this.Type = null;
}
return this.Level;
}
}
public void addLevel(Fluid type, int lvl) {
if (type != null) {
this.Type = type;
this.Delta += lvl;
this.onChange();
}
}
public Fluid getFluidClass() {
return this.Type;
}
public void readFromNBT(NBTTagCompound tag, String name) {
NBTTagCompound t2 = tag.getCompoundTag(name);
this.Type = FluidRegistry.getFluid(t2.getString("type"));
this.Level = t2.getShort("lvl");
this.Delta = t2.getShort("del");
this.lastTick = t2.getShort("ltk");
}
public void writeToNBT(NBTTagCompound tag, String name) {
NBTTagCompound t2 = new NBTTagCompound();
String n = FluidRegistry.getFluidName(this.Type);
t2.setString("type", n != null && !n.isEmpty() ? n : "null");
t2.setShort("lvl", (short)this.Level);
t2.setShort("del", (short)this.Delta);
t2.setShort("ltk", (short)this.lastTick);
tag.setTag(name, t2);
}
public void writeToPacket(NBTTagCompound tag) {
tag.setInteger("type", this.Type == null ? -1 : FluidRegistry.getFluidID(this.Type));
tag.setInteger("lvl", this.Level);
}
public void readFromPacket(NBTTagCompound buffer) {
this.Type = FluidRegistry.getFluid(buffer.getInteger("type"));
this.Level = buffer.getInteger("lvl");
}
}

View File

@ -0,0 +1,220 @@
package com.eloraam.redpower.core;
public class FractalLib {
public static long hash64shift(long key) {
key = ~key + (key << 21);
key ^= key >>> 24;
key = key + (key << 3) + (key << 8);
key ^= key >>> 14;
key = key + (key << 2) + (key << 4);
key ^= key >>> 28;
return key + (key << 31);
}
public static double hashFloat(long key) {
long f = hash64shift(key);
return Double.longBitsToDouble(4607182418800017408L | f & 4503599627370495L) - 1.0;
}
public static double noise1D(long seed, double pos, float lac, int octave) {
double tr = 0.5;
double scale = (double)(1 << octave);
for(int i = 0; i < octave; ++i) {
double p = pos * scale;
long pint = (long)Math.floor(p);
double m1 = hashFloat(seed + pint);
double m2 = hashFloat(seed + pint + 1L);
p -= Math.floor(p);
double v = 0.5 + 0.5 * Math.cos(Math.PI * p);
v = v * m1 + (1.0 - v) * m2;
tr = (double)(1.0F - lac) * tr + (double)lac * v;
scale *= 0.5;
}
return tr;
}
public static double perturbOld(long seed, float pos, float lac, int octave) {
double tr = 0.0;
double mscale = 1.0;
double scale = 1.0;
for(int i = 0; i < octave; ++i) {
long v = (long)Math.floor((double)pos * scale);
long p = hash64shift(seed + v);
double mag = Double.longBitsToDouble(4607182418800017408L | p & 4503599627370495L) - 1.0;
tr += mscale * mag * Math.sin(Math.PI * 2 * (double)pos * scale);
scale *= 2.0;
mscale *= (double)lac;
}
return tr;
}
public static void fillVector(Vector3 v, Vector3 org, Vector3 dest, float pos, long seed) {
double window = 4.0 * Math.sin(Math.PI * (double)pos);
v.x = org.x + (double)(pos * pos) * dest.x + window * perturbOld(seed, pos, 0.7F, 5);
v.y = org.y + (double)pos * dest.y + window * perturbOld(seed + 1L, pos, 0.7F, 5);
v.z = org.z + (double)(pos * pos) * dest.z + window * perturbOld(seed + 2L, pos, 0.7F, 5);
}
public static int mdist(Vector3 a, Vector3 b) {
return (int)(Math.abs(Math.floor(a.x) - Math.floor(b.x)) + Math.abs(Math.floor(a.y) - Math.floor(b.y)) + Math.abs(Math.floor(a.z) - Math.floor(b.z)));
}
public static class BlockRay {
private Vector3 p1;
private Vector3 p2;
private Vector3 dv;
public Vector3 enter;
public Vector3 exit;
public int xp;
public int yp;
public int zp;
public int dir;
public int face;
public BlockRay(Vector3 s, Vector3 d) {
this.p1 = new Vector3(s);
this.p2 = new Vector3(d);
this.dv = new Vector3(d);
this.dv.subtract(s);
this.exit = new Vector3(s);
this.enter = new Vector3();
this.xp = (int)Math.floor(s.x);
this.yp = (int)Math.floor(s.y);
this.zp = (int)Math.floor(s.z);
this.dir = 0;
this.dir |= d.x > s.x ? 4 : 0;
this.dir |= d.y > s.y ? 1 : 0;
this.dir |= d.z > s.z ? 2 : 0;
}
public void set(Vector3 s, Vector3 d) {
this.p1.set(s);
this.p2.set(d);
this.dv.set(d);
this.dv.subtract(s);
this.exit.set(s);
this.xp = (int)Math.floor(s.x);
this.yp = (int)Math.floor(s.y);
this.zp = (int)Math.floor(s.z);
this.dir = 0;
this.dir |= d.x > s.x ? 4 : 0;
this.dir |= d.y > s.y ? 1 : 0;
this.dir |= d.z > s.z ? 2 : 0;
}
boolean step() {
double bp = 1.0;
int sd = -1;
if (this.dv.x != 0.0) {
int x = this.xp;
if ((this.dir & 4) > 0) {
++x;
}
double d = ((double)x - this.p1.x) / this.dv.x;
if (d >= 0.0 && d <= bp) {
bp = d;
sd = (this.dir & 4) > 0 ? 4 : 5;
}
}
if (this.dv.y != 0.0) {
int y = this.yp;
if ((this.dir & 1) > 0) {
++y;
}
double d = ((double)y - this.p1.y) / this.dv.y;
if (d >= 0.0 && d <= bp) {
bp = d;
sd = (this.dir & 1) > 0 ? 0 : 1;
}
}
if (this.dv.z != 0.0) {
int z = this.zp;
if ((this.dir & 2) > 0) {
++z;
}
double d = ((double)z - this.p1.z) / this.dv.z;
if (d >= 0.0 && d <= bp) {
bp = d;
sd = (this.dir & 2) > 0 ? 2 : 3;
}
}
this.face = sd;
switch(sd) {
case 0:
++this.yp;
break;
case 1:
--this.yp;
break;
case 2:
++this.zp;
break;
case 3:
--this.zp;
break;
case 4:
++this.xp;
break;
case 5:
--this.xp;
}
this.enter.set(this.exit);
this.exit.set(this.dv);
this.exit.multiply(bp);
this.exit.add(this.p1);
return bp >= 1.0;
}
}
public static class BlockSnake {
int fep = -1;
FractalLib.BlockRay ray;
Vector3 org;
Vector3 dest;
Vector3 fracs;
Vector3 frace;
long seed;
public BlockSnake(Vector3 o, Vector3 d, long s) {
this.org = new Vector3(o);
this.dest = new Vector3(d);
this.fracs = new Vector3(o);
this.frace = new Vector3();
this.seed = s;
FractalLib.fillVector(this.frace, this.org, this.dest, 0.125F, this.seed);
this.ray = new FractalLib.BlockRay(this.fracs, this.frace);
}
public boolean iterate() {
if (this.fep == -1) {
++this.fep;
return true;
} else if (!this.ray.step()) {
return true;
} else if (this.fep == 8) {
return false;
} else {
this.fracs.set(this.frace);
FractalLib.fillVector(this.frace, this.org, this.dest, (float)this.fep / 8.0F, this.seed);
this.ray.set(this.fracs, this.frace);
++this.fep;
return true;
}
}
public Vector3 get() {
return new Vector3((double)this.ray.xp, (double)this.ray.yp, (double)this.ray.zp);
}
}
}

Some files were not shown because too many files have changed in this diff Show More