mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
electric press functionality, grenade pistol, gun "fun" stats
This commit is contained in:
parent
974b49a617
commit
94795bbbf1
@ -410,6 +410,8 @@ tile.safe.name=Panzerschrank
|
||||
container.safe=Panzerschrank
|
||||
tile.machine_press.name=Befeuerte Presse
|
||||
container.press=Befeuerte Presse
|
||||
tile.machine_epress.name=Hydraulische Presse
|
||||
container.epress=Hydraulische Presse
|
||||
tile.machine_siren.name=Sirene
|
||||
container.siren=Sirene
|
||||
tile.machine_radgen.name=Strahlenbetriebener Generator
|
||||
|
||||
@ -410,6 +410,8 @@ tile.safe.name=Safe
|
||||
container.safe=Safe
|
||||
tile.machine_press.name=Burner Press
|
||||
container.press=Burner Press
|
||||
tile.machine_epress.name=Electric Press
|
||||
container.epress=Electric Press
|
||||
tile.machine_siren.name=Siren
|
||||
container.siren=Siren
|
||||
tile.machine_radgen.name=Radiation-Powered Engine
|
||||
|
||||
BIN
assets/hbm/textures/blocks/machine_epress.png
Normal file
BIN
assets/hbm/textures/blocks/machine_epress.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 221 B |
BIN
assets/hbm/textures/gui/gui_epress.png
Normal file
BIN
assets/hbm/textures/gui/gui_epress.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/hbm/textures/items/gun_hk69.png
Normal file
BIN
assets/hbm/textures/items/gun_hk69.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 196 B |
@ -1,14 +1,31 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
import com.hbm.tileentity.machine.TileEntityRtgFurnace;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
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.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineEPress extends BlockContainer {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private static boolean keepInventory;
|
||||
|
||||
public MachineEPress(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
@ -33,5 +50,101 @@ public class MachineEPress extends BlockContainer {
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
|
||||
{
|
||||
if (!keepInventory)
|
||||
{
|
||||
ISidedInventory tileentityfurnace = (ISidedInventory)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
|
||||
|
||||
if (tileentityfurnace != null)
|
||||
{
|
||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
|
||||
{
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
int j1 = this.field_149933_a.nextInt(21) + 10;
|
||||
|
||||
if (j1 > itemstack.stackSize)
|
||||
{
|
||||
j1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
p_149749_1_.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
if(i == 1)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
if(i == 2)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
if(i == 3)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
|
||||
if(itemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityMachineEPress)world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(x, y, z);
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_epress, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,9 @@ public class EntityNukeExplosionMK4 extends Entity {
|
||||
|
||||
if(explosion == null) {
|
||||
explosion = new ExplosionNukeRay(worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, this.strength, this.count, this.speed, this.length);
|
||||
|
||||
|
||||
MainRegistry.logger.info("START: " + System.currentTimeMillis());
|
||||
|
||||
/*if(!worldObj.isRemote)
|
||||
for(int x = (int) (posX - 1); x <= (int) (posX + 1); x++)
|
||||
for(int y = (int) (posY - 1); y <= (int) (posY + 1); y++)
|
||||
@ -82,6 +84,8 @@ public class EntityNukeExplosionMK4 extends Entity {
|
||||
//MainRegistry.logger.info(explosion.getProgress() + " / " + count / length);
|
||||
explosion.processTip(1024);
|
||||
} else if(fallout) {
|
||||
|
||||
MainRegistry.logger.info("STOP: " + System.currentTimeMillis());
|
||||
|
||||
EntityFalloutRain fallout = new EntityFalloutRain(this.worldObj, (int)(this.length * 0.9) * 2 * MainRegistry.falloutDura / 10);
|
||||
fallout.posX = this.posX;
|
||||
|
||||
@ -235,7 +235,7 @@ public class EntityBulletBase extends Entity implements IProjectile {
|
||||
boolean doesRic = config.doesRicochet || hRic;
|
||||
|
||||
if(!config.isSpectral && !doesRic)
|
||||
this.setDead();
|
||||
this.onBlockImpact(movement.blockX, movement.blockY, movement.blockZ);
|
||||
|
||||
if(doesRic) {
|
||||
|
||||
@ -379,6 +379,11 @@ public class EntityBulletBase extends Entity implements IProjectile {
|
||||
if(config.shrapnel > 0 && !worldObj.isRemote)
|
||||
ExplosionLarge.spawnShrapnels(worldObj, posX, posY, posZ, config.shrapnel);
|
||||
|
||||
if(config.chlorine > 0 && !worldObj.isRemote) {
|
||||
ExplosionChaos.spawnChlorine(worldObj, posX, posY, posZ, config.chlorine, 1.5, 0);
|
||||
worldObj.playSoundEffect((double)(posX + 0.5F), (double)(posY + 0.5F), (double)(posZ + 0.5F), "random.fizz", 5.0F, 2.6F + (rand.nextFloat() - rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
|
||||
if(config.rainbow > 0 && !worldObj.isRemote) {
|
||||
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 100.0f, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
|
||||
@ -315,6 +315,7 @@ public class ExplosionNukeRay {
|
||||
isAusf3Complete = true;
|
||||
}*/
|
||||
|
||||
//currently used by mk4
|
||||
public void collectTipMk4_5(int count) {
|
||||
|
||||
int amountProcessed = 0;
|
||||
|
||||
@ -115,6 +115,31 @@ public class BulletConfigFactory {
|
||||
return bullet;
|
||||
}
|
||||
|
||||
protected static BulletConfiguration standardGrenadeConfig() {
|
||||
|
||||
BulletConfiguration bullet = new BulletConfiguration();
|
||||
|
||||
bullet.velocity = 2.0F;
|
||||
bullet.spread = 0.005F;
|
||||
bullet.wear = 10;
|
||||
bullet.bulletsMin = 1;
|
||||
bullet.bulletsMax = 1;
|
||||
bullet.gravity = 0.05D;
|
||||
bullet.maxAge = 300;
|
||||
bullet.doesRicochet = false;
|
||||
bullet.ricochetAngle = 0;
|
||||
bullet.HBRC = 0;
|
||||
bullet.LBRC = 0;
|
||||
bullet.bounceMod = 1.0;
|
||||
bullet.doesPenetrate = false;
|
||||
bullet.doesBreakGlass = false;
|
||||
bullet.explosive = 2.5F;
|
||||
bullet.style = BulletConfiguration.STYLE_GRENADE;
|
||||
bullet.plink = BulletConfiguration.PLINK_GRENADE;
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
/// ADJUSTED CONFIGS ///
|
||||
|
||||
/// .357 ///
|
||||
@ -390,5 +415,80 @@ public class BulletConfigFactory {
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
protected static BulletConfiguration getGrenadeConfig() {
|
||||
|
||||
BulletConfiguration bullet = standardGrenadeConfig();
|
||||
|
||||
bullet.ammo = ModItems.ammo_grenade;
|
||||
bullet.velocity = 2.0F;
|
||||
bullet.dmgMin = 10;
|
||||
bullet.dmgMax = 15;
|
||||
bullet.wear = 10;
|
||||
bullet.trail = 0;
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
protected static BulletConfiguration getGrenadeHEConfig() {
|
||||
|
||||
BulletConfiguration bullet = standardGrenadeConfig();
|
||||
|
||||
bullet.ammo = ModItems.ammo_grenade_he;
|
||||
bullet.velocity = 2.0F;
|
||||
bullet.dmgMin = 20;
|
||||
bullet.dmgMax = 15;
|
||||
bullet.wear = 10;
|
||||
bullet.explosive = 5.0F;
|
||||
bullet.trail = 1;
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
protected static BulletConfiguration getGrenadeIncendirayConfig() {
|
||||
|
||||
BulletConfiguration bullet = standardGrenadeConfig();
|
||||
|
||||
bullet.ammo = ModItems.ammo_grenade_incendiary;
|
||||
bullet.velocity = 2.0F;
|
||||
bullet.dmgMin = 15;
|
||||
bullet.dmgMax = 15;
|
||||
bullet.wear = 10;
|
||||
bullet.trail = 0;
|
||||
bullet.incendiary = 2;
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
protected static BulletConfiguration getGrenadeChlorineConfig() {
|
||||
|
||||
BulletConfiguration bullet = standardGrenadeConfig();
|
||||
|
||||
bullet.ammo = ModItems.ammo_grenade_toxic;
|
||||
bullet.velocity = 2.0F;
|
||||
bullet.dmgMin = 10;
|
||||
bullet.dmgMax = 15;
|
||||
bullet.wear = 10;
|
||||
bullet.trail = 3;
|
||||
bullet.explosive = 0;
|
||||
bullet.chlorine = 50;
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
protected static BulletConfiguration getGrenadeSleekConfig() {
|
||||
|
||||
BulletConfiguration bullet = standardGrenadeConfig();
|
||||
|
||||
bullet.ammo = ModItems.ammo_grenade_sleek;
|
||||
bullet.velocity = 2.0F;
|
||||
bullet.dmgMin = 10;
|
||||
bullet.dmgMax = 15;
|
||||
bullet.wear = 10;
|
||||
bullet.trail = 4;
|
||||
bullet.explosive = 7.5F;
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,6 +41,12 @@ public class BulletConfigSyncingUtil {
|
||||
public static final int ROCKET_EMP = 0x24;
|
||||
public static final int ROCKET_GLARE = 0x25;
|
||||
public static final int ROCKET_SLEEK = 0x26;
|
||||
|
||||
public static final int GRENADE_NORMAL = 0x30;
|
||||
public static final int GRENADE_HE = 0x31;
|
||||
public static final int GRENADE_INCENDIARY = 0x32;
|
||||
public static final int GRENADE_CHEMICAL = 0x33;
|
||||
public static final int GRENADE_SLEEK = 0x34;
|
||||
|
||||
public static void loadConfigsForSync() {
|
||||
|
||||
@ -61,6 +67,12 @@ public class BulletConfigSyncingUtil {
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getRocketEMPConfig(), ROCKET_EMP));
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getRocketGlareConfig(), ROCKET_GLARE));
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getRocketSleekConfig(), ROCKET_SLEEK));
|
||||
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeConfig(), GRENADE_NORMAL));
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeHEConfig(), GRENADE_HE));
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeIncendirayConfig(), GRENADE_INCENDIARY));
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeChlorineConfig(), GRENADE_CHEMICAL));
|
||||
configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeSleekConfig(), GRENADE_SLEEK));
|
||||
}
|
||||
|
||||
public static BulletConfiguration pullConfig(int key) {
|
||||
|
||||
@ -55,6 +55,7 @@ public class BulletConfiguration {
|
||||
public int rainbow;
|
||||
public int nuke;
|
||||
public int shrapnel;
|
||||
public int chlorine;
|
||||
public boolean boxcar;
|
||||
public boolean boat;
|
||||
public boolean destroysBlocks;
|
||||
|
||||
@ -722,6 +722,15 @@ public class GUIHandler implements IGuiHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_machine_epress:
|
||||
{
|
||||
if(entity instanceof TileEntityMachineEPress)
|
||||
{
|
||||
return new ContainerMachineEPress(player.inventory, (TileEntityMachineEPress) entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//CLIENTONLY CONTAINERS
|
||||
@ -1444,6 +1453,15 @@ public class GUIHandler implements IGuiHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_machine_epress:
|
||||
{
|
||||
if(entity instanceof TileEntityMachineEPress)
|
||||
{
|
||||
return new GUIMachineEPress(player.inventory, (TileEntityMachineEPress) entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//CLIENTONLY GUIS
|
||||
|
||||
@ -26,6 +26,9 @@ public class GunConfigFactory {
|
||||
config.crosshair = Crosshair.L_CLASSIC;
|
||||
config.durability = 350;
|
||||
|
||||
config.name = "FFI Viper";
|
||||
config.manufacturer = "FlimFlam Industries";
|
||||
|
||||
config.config = new ArrayList<Integer>();
|
||||
config.config.add(BulletConfigSyncingUtil.STEEL_REVOLVER);
|
||||
config.config.add(BulletConfigSyncingUtil.IRON_REVOLVER);
|
||||
@ -52,6 +55,9 @@ public class GunConfigFactory {
|
||||
config.crosshair = Crosshair.L_CIRCLE;
|
||||
config.durability = 350;
|
||||
|
||||
config.name = "Winchester Model 1887";
|
||||
config.manufacturer = "Winchester Repeating Arms Company";
|
||||
|
||||
config.config = new ArrayList<Integer>();
|
||||
config.config.add(BulletConfigSyncingUtil.G20_NORMAL);
|
||||
config.config.add(BulletConfigSyncingUtil.G20_SLUG);
|
||||
@ -80,6 +86,9 @@ public class GunConfigFactory {
|
||||
config.allowsInfinity = true;
|
||||
config.crosshair = Crosshair.L_CIRCUMFLEX;
|
||||
|
||||
config.name = "Carl Gustav Recoilless Rifle M1";
|
||||
config.manufacturer = "Saab Bofors Dynamics";
|
||||
|
||||
config.config = new ArrayList<Integer>();
|
||||
config.config.add(BulletConfigSyncingUtil.ROCKET_NORMAL);
|
||||
config.config.add(BulletConfigSyncingUtil.ROCKET_HE);
|
||||
@ -92,5 +101,37 @@ public class GunConfigFactory {
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static GunConfiguration getGrenadeConfig() {
|
||||
|
||||
GunConfiguration config = new GunConfiguration();
|
||||
|
||||
config.rateOfFire = 30;
|
||||
config.gunMode = GunConfiguration.MODE_NORMAL;
|
||||
config.firingMode = GunConfiguration.FIRE_MANUAL;
|
||||
config.hasReloadAnim = false;
|
||||
config.hasFiringAnim = false;
|
||||
config.hasSpinup = false;
|
||||
config.hasSpindown = false;
|
||||
config.reloadDuration = 40;
|
||||
config.firingDuration = 0;
|
||||
config.ammoCap = 1;
|
||||
config.reloadType = GunConfiguration.RELOAD_SINGLE;
|
||||
config.allowsInfinity = true;
|
||||
config.crosshair = Crosshair.L_CIRCUMFLEX;
|
||||
|
||||
config.name = "Granatpistole HK69";
|
||||
config.manufacturer = "Heckler & Koch";
|
||||
|
||||
config.config = new ArrayList<Integer>();
|
||||
config.config.add(BulletConfigSyncingUtil.GRENADE_NORMAL);
|
||||
config.config.add(BulletConfigSyncingUtil.GRENADE_HE);
|
||||
config.config.add(BulletConfigSyncingUtil.GRENADE_INCENDIARY);
|
||||
config.config.add(BulletConfigSyncingUtil.GRENADE_CHEMICAL);
|
||||
config.config.add(BulletConfigSyncingUtil.GRENADE_SLEEK);
|
||||
config.durability = 140;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -44,6 +44,9 @@ public class GunConfiguration {
|
||||
public int reloadType;
|
||||
//whether or not the infinity enchantment should work
|
||||
public boolean allowsInfinity;
|
||||
|
||||
public String name;
|
||||
public String manufacturer;
|
||||
|
||||
//bullet configs for main and alt fire
|
||||
public List<Integer> config;
|
||||
|
||||
@ -9,6 +9,7 @@ import java.util.Map;
|
||||
|
||||
import com.hbm.handler.nei.ShredderRecipeHandler.Fuel;
|
||||
import com.hbm.inventory.MachineRecipes;
|
||||
import com.hbm.inventory.gui.GUIMachineEPress;
|
||||
import com.hbm.inventory.gui.GUIMachinePress;
|
||||
import com.hbm.inventory.gui.GUIMachineShredder;
|
||||
import com.hbm.items.ModItems;
|
||||
@ -149,6 +150,7 @@ public class PressRecipeHandler extends TemplateRecipeHandler {
|
||||
transferRectsGui.add(new RecipeTransferRect(new Rectangle(74 + 6 + 18, 23, 24, 18), "pressing"));
|
||||
//guiRec.add(GuiRecipe.class);
|
||||
guiGui.add(GUIMachinePress.class);
|
||||
guiGui.add(GUIMachineEPress.class);
|
||||
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
|
||||
//RecipeTransferRectHandler.registerRectsToGuis(guiRec, transferRectsRec);
|
||||
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
|
||||
|
||||
111
com/hbm/inventory/container/ContainerMachineEPress.java
Normal file
111
com/hbm/inventory/container/ContainerMachineEPress.java
Normal file
@ -0,0 +1,111 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotMachineOutput;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
|
||||
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 ContainerMachineEPress extends Container {
|
||||
|
||||
private TileEntityMachineEPress nukeBoy;
|
||||
|
||||
private int progress;
|
||||
|
||||
public ContainerMachineEPress(InventoryPlayer invPlayer, TileEntityMachineEPress tedf) {
|
||||
|
||||
nukeBoy = tedf;
|
||||
|
||||
//Battery
|
||||
this.addSlotToContainer(new Slot(tedf, 0, 44, 53));
|
||||
//Stamp
|
||||
this.addSlotToContainer(new Slot(tedf, 1, 80, 17));
|
||||
//Input
|
||||
this.addSlotToContainer(new Slot(tedf, 2, 80, 53));
|
||||
//Output
|
||||
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 3, 140, 35));
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
for(int j = 0; j < 9; j++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2)
|
||||
{
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack())
|
||||
{
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if (par2 <= 3) {
|
||||
if (!this.mergeItemStack(var5, 4, this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var5, 2, 3, false))
|
||||
if (!this.mergeItemStack(var5, 0, 1, false))
|
||||
if (!this.mergeItemStack(var5, 1, 2, false))
|
||||
return null;
|
||||
|
||||
if (var5.stackSize == 0)
|
||||
{
|
||||
var4.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return nukeBoy.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for(int i = 0; i < this.crafters.size(); i++)
|
||||
{
|
||||
ICrafting par1 = (ICrafting)this.crafters.get(i);
|
||||
|
||||
if(this.progress != this.nukeBoy.progress)
|
||||
{
|
||||
par1.sendProgressBarUpdate(this, 0, this.nukeBoy.progress);
|
||||
}
|
||||
}
|
||||
|
||||
this.progress = this.nukeBoy.progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
if(i == 0)
|
||||
{
|
||||
nukeBoy.progress = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
com/hbm/inventory/gui/GUIMachineEPress.java
Normal file
58
com/hbm/inventory/gui/GUIMachineEPress.java
Normal file
@ -0,0 +1,58 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.handler.FluidTypeHandler.FluidType;
|
||||
import com.hbm.inventory.container.ContainerMachineEPress;
|
||||
import com.hbm.inventory.container.ContainerMachinePress;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineEPress extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_epress.png");
|
||||
private TileEntityMachineEPress press;
|
||||
|
||||
public GUIMachineEPress(InventoryPlayer invPlayer, TileEntityMachineEPress tedf) {
|
||||
super(new ContainerMachineEPress(invPlayer, tedf));
|
||||
press = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 26, guiTop + 69 - 52, 16, 52, press.power, press.maxPower);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer( int i, int j) {
|
||||
String name = this.press.hasCustomInventoryName() ? this.press.getInventoryName() : I18n.format(this.press.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int i = (int)press.getPowerScaled(52);
|
||||
drawTexturedModalRect(guiLeft + 26, guiTop + 69 - i, 176, 52 - i, 16, i);
|
||||
|
||||
int k = press.getProgressScaled(16);
|
||||
this.drawTexturedModalRect(guiLeft + 79, guiTop + 35, 192, 0, 18, k);
|
||||
}
|
||||
}
|
||||
@ -852,6 +852,7 @@ public class ModItems {
|
||||
|
||||
public static Item gun_rpg;
|
||||
public static Item gun_rpg_ammo;
|
||||
public static Item gun_hk69;
|
||||
public static Item gun_stinger;
|
||||
public static Item gun_skystinger;
|
||||
public static Item gun_stinger_ammo;
|
||||
@ -2298,6 +2299,7 @@ public class ModItems {
|
||||
|
||||
gun_rpg = new ItemGunBase(GunConfigFactory.getGustavConfig()).setUnlocalizedName("gun_rpg").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_rpg");
|
||||
gun_rpg_ammo = new Item().setUnlocalizedName("gun_rpg_ammo").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_rpg_ammo_alt");
|
||||
gun_hk69 = new ItemGunBase(GunConfigFactory.getGrenadeConfig()).setUnlocalizedName("gun_hk69").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_hk69");
|
||||
gun_stinger = new GunStinger().setUnlocalizedName("gun_stinger").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_stinger");
|
||||
gun_skystinger = new GunStinger().setUnlocalizedName("gun_skystinger").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_skystinger");
|
||||
gun_stinger_ammo = new Item().setUnlocalizedName("gun_stinger_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_stinger_ammo");
|
||||
@ -3914,6 +3916,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(gun_b92, gun_b92.getUnlocalizedName());
|
||||
GameRegistry.registerItem(gun_b93, gun_b93.getUnlocalizedName());
|
||||
GameRegistry.registerItem(gun_rpg, gun_rpg.getUnlocalizedName());
|
||||
GameRegistry.registerItem(gun_hk69, gun_hk69.getUnlocalizedName());
|
||||
GameRegistry.registerItem(gun_stinger, gun_stinger.getUnlocalizedName());
|
||||
GameRegistry.registerItem(gun_fatman, gun_fatman.getUnlocalizedName());
|
||||
GameRegistry.registerItem(gun_proto, gun_proto.getUnlocalizedName());
|
||||
|
||||
@ -58,7 +58,7 @@ public class GunLeverAction extends Item {
|
||||
boolean flag = p_77615_3_.capabilities.isCreativeMode
|
||||
|| EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
|
||||
|
||||
if (flag || p_77615_3_.inventory.hasItem(ModItems.ammo_12gauge)) {
|
||||
if (flag || p_77615_3_.inventory.hasItem(ModItems.ammo_20gauge)) {
|
||||
float f = j / 20.0F;
|
||||
f = (f * f + f * 2.0F) / 3.0F;
|
||||
|
||||
@ -109,7 +109,7 @@ public class GunLeverAction extends Item {
|
||||
p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.revolverShootAlt", 5.0F, 0.75F);
|
||||
|
||||
if (flag) { } else {
|
||||
p_77615_3_.inventory.consumeInventoryItem(ModItems.ammo_12gauge);
|
||||
p_77615_3_.inventory.consumeInventoryItem(ModItems.ammo_20gauge);
|
||||
}
|
||||
|
||||
if (!p_77615_2_.isRemote) {
|
||||
|
||||
@ -25,7 +25,7 @@ public class HbmChestContents {
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver, 0, 1, 1, 3),
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver_ammo, 0, 2, 6, 4),
|
||||
new WeightedRandomChestContent(ModItems.gun_lever_action, 0, 1, 1, 1),
|
||||
new WeightedRandomChestContent(ModItems.gun_lever_action_ammo, 0, 2, 6, 3),
|
||||
new WeightedRandomChestContent(ModItems.ammo_20gauge, 0, 2, 6, 3),
|
||||
new WeightedRandomChestContent(ModItems.battery_generic, 0, 1, 1, 4),
|
||||
new WeightedRandomChestContent(ModItems.battery_advanced, 0, 1, 1, 2),
|
||||
new WeightedRandomChestContent(ModItems.scrap, 0, 1, 3, 10),
|
||||
@ -72,13 +72,13 @@ public class HbmChestContents {
|
||||
new WeightedRandomChestContent(ModItems.circuit_gold, 0, 1, 2, 3),
|
||||
new WeightedRandomChestContent(ModItems.circuit_targeting_tier4, 0, 1, 1, 2),
|
||||
new WeightedRandomChestContent(ModItems.gun_lever_action, 0, 1, 1, 5),
|
||||
new WeightedRandomChestContent(ModItems.gun_lever_action_ammo, 0, 2, 6, 6),
|
||||
new WeightedRandomChestContent(ModItems.ammo_20gauge, 0, 2, 6, 6),
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver_gold, 0, 1, 1, 4),
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver_gold_ammo, 0, 1, 6, 5),
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver_lead, 0, 1, 1, 4),
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver_lead_ammo, 0, 1, 6, 5),
|
||||
new WeightedRandomChestContent(ModItems.gun_rpg, 0, 1, 1, 4),
|
||||
new WeightedRandomChestContent(ModItems.gun_rpg_ammo, 0, 1, 4, 5),
|
||||
new WeightedRandomChestContent(ModItems.ammo_rocket, 0, 1, 4, 5),
|
||||
new WeightedRandomChestContent(ModItems.gun_fatman, 0, 1, 1, 1),
|
||||
new WeightedRandomChestContent(ModItems.gun_fatman_ammo, 0, 1, 2, 2),
|
||||
new WeightedRandomChestContent(ModItems.grenade_nuclear, 0, 1, 1, 2),
|
||||
@ -159,7 +159,7 @@ public class HbmChestContents {
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver, 0, 1, 1, 4),
|
||||
new WeightedRandomChestContent(ModItems.gun_revolver_ammo, 0, 1, 24, 4),
|
||||
new WeightedRandomChestContent(ModItems.gun_rpg, 0, 1, 1, 3),
|
||||
new WeightedRandomChestContent(ModItems.gun_rpg_ammo, 0, 1, 6, 3),
|
||||
new WeightedRandomChestContent(ModItems.ammo_rocket, 0, 1, 6, 3),
|
||||
new WeightedRandomChestContent(ModItems.rod_uranium_fuel, 0, 1, 1, 2),
|
||||
new WeightedRandomChestContent(ModItems.rod_dual_uranium_fuel, 0, 1, 1, 2),
|
||||
new WeightedRandomChestContent(ModItems.rod_quad_uranium_fuel, 0, 1, 1, 2),
|
||||
@ -235,7 +235,7 @@ public class HbmChestContents {
|
||||
new WeightedRandomChestContent(ModItems.gun_calamity, 0, 1, 1, 1),
|
||||
new WeightedRandomChestContent(ModItems.bottle_quantum, 0, 1, 3, 1),
|
||||
new WeightedRandomChestContent(ModItems.ingot_advanced_alloy, 0, 4, 12, 1),
|
||||
new WeightedRandomChestContent(ModItems.gun_calamity_ammo, 0, 24, 48, 1),
|
||||
new WeightedRandomChestContent(ModItems.ammo_50bmg, 0, 24, 48, 1),
|
||||
new WeightedRandomChestContent(ModItems.circuit_red_copper, 0, 6, 12, 1),
|
||||
new WeightedRandomChestContent(ModItems.gas_mask_m65, 0, 1, 1, 1),
|
||||
new WeightedRandomChestContent(ModItems.grenade_if_he, 0, 1, 1, 1),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineTurbofan;
|
||||
|
||||
@ -74,6 +75,13 @@ public class TEPressPacket implements IMessage {
|
||||
gen.meta = m.meta;
|
||||
gen.progress = m.progress;
|
||||
}
|
||||
if (te != null && te instanceof TileEntityMachineEPress) {
|
||||
|
||||
TileEntityMachineEPress gen = (TileEntityMachineEPress) te;
|
||||
gen.item = m.item;
|
||||
gen.meta = m.meta;
|
||||
gen.progress = m.progress;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
public class RenderScreenOverlay {
|
||||
|
||||
private static final ResourceLocation misc = new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_misc.png");
|
||||
private static final ResourceLocation hud = new ResourceLocation("textures/gui/widgets.png");
|
||||
|
||||
private static long lastSurvey;
|
||||
private static float prevResult;
|
||||
@ -77,6 +78,7 @@ public class RenderScreenOverlay {
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glPopMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(hud);
|
||||
}
|
||||
|
||||
private static int getScaled(double cur, double max, double scale) {
|
||||
@ -88,13 +90,16 @@ public class RenderScreenOverlay {
|
||||
public static void renderCustomCrosshairs(ScaledResolution resolution, Gui gui, Crosshair cross) {
|
||||
|
||||
int size = cross.size;
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(misc);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0);
|
||||
gui.drawTexturedModalRect(resolution.getScaledWidth() / 2 - (size / 2), resolution.getScaledHeight() / 2 - (size / 2), cross.x, cross.y, size, size);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(misc);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0);
|
||||
gui.drawTexturedModalRect(resolution.getScaledWidth() / 2 - (size / 2), resolution.getScaledHeight() / 2 - (size / 2), cross.x, cross.y, size, size);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(hud);
|
||||
}
|
||||
|
||||
public enum Crosshair {
|
||||
|
||||
@ -3,7 +3,7 @@ package com.hbm.render.tileentity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
@ -28,6 +28,17 @@ public class RenderEPress extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
|
||||
switch(tileentity.getBlockMetadata()) {
|
||||
case 2:
|
||||
GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
case 4:
|
||||
GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 3:
|
||||
GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 5:
|
||||
GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
this.bindTexture(ResourceManager.epress_body_tex);
|
||||
|
||||
ResourceManager.epress_body.renderAll();
|
||||
@ -37,15 +48,26 @@ public class RenderEPress extends TileEntitySpecialRenderer {
|
||||
renderTileEntityAt2(tileentity, x, y, z, f);
|
||||
}
|
||||
|
||||
public void renderTileEntityAt2(TileEntity tileEntity, double x, double y, double z, float f) {
|
||||
public void renderTileEntityAt2(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y + 1 + 1 - 0.125, z + 0.5D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
|
||||
switch(tileentity.getBlockMetadata()) {
|
||||
case 2:
|
||||
GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
case 4:
|
||||
GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 3:
|
||||
GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 5:
|
||||
GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
//TileEntityMachinePress press = (TileEntityMachinePress)tileEntity;
|
||||
//float f1 = press.progress * (1 - 0.125F) / press.maxProgress;
|
||||
//GL11.glTranslated(0, -f1, 0);
|
||||
TileEntityMachineEPress press = (TileEntityMachineEPress)tileentity;
|
||||
float f1 = press.progress * (1 - 0.125F) / press.maxProgress;
|
||||
GL11.glTranslated(0, -f1, 0);
|
||||
|
||||
this.bindTexture(ResourceManager.epress_head_tex);
|
||||
|
||||
@ -53,26 +75,40 @@ public class RenderEPress extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
//renderTileEntityAt3(tileEntity, x, y, z, f);
|
||||
renderTileEntityAt3(tileentity, x, y, z, f);
|
||||
}
|
||||
|
||||
public void renderTileEntityAt3(TileEntity tileEntity, double x, double y, double z, float f) {
|
||||
public void renderTileEntityAt3(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
itemRenderer = new RenderDecoItem(this);
|
||||
itemRenderer.setRenderManager(renderManager);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y + 1, z - 0.5);
|
||||
GL11.glTranslated(x + 0.5D, y + 1, z + 0.5);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
GL11.glRotatef(-90, 1F, 0F, 0F);
|
||||
|
||||
TileEntityMachinePress press = (TileEntityMachinePress)tileEntity;
|
||||
switch(tileentity.getBlockMetadata()) {
|
||||
case 2:
|
||||
GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
case 4:
|
||||
GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 3:
|
||||
GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 5:
|
||||
GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
GL11.glRotatef(90, 0F, 1F, 0F);
|
||||
GL11.glRotatef(-90, 1F, 0F, 0F);
|
||||
GL11.glTranslatef(1.0F, 1.0F - 0.0625F * 165/100, 0.0F);
|
||||
GL11.glTranslatef(-1, -1.15F, 0);
|
||||
|
||||
TileEntityMachineEPress press = (TileEntityMachineEPress)tileentity;
|
||||
ItemStack stack = new ItemStack(Item.getItemById(press.item), 1, press.meta);
|
||||
|
||||
if(!(stack.getItem() instanceof ItemBlock)) {
|
||||
EntityItem item = new EntityItem(null, 0.0D, 0.0D, 0.0D, stack);
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
GL11.glTranslatef(0.0F, 1.0F - 0.0625F * 165/100, 0.0F);
|
||||
this.itemRenderer.doRender(item, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
}
|
||||
|
||||
@ -1,7 +1,299 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.interfaces.IConsumer;
|
||||
import com.hbm.inventory.MachineRecipes;
|
||||
import com.hbm.items.special.ItemBlades;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.AuxElectricityPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.TEPressPacket;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class TileEntityMachineEPress extends TileEntity {
|
||||
public class TileEntityMachineEPress extends TileEntity implements ISidedInventory, IConsumer {
|
||||
|
||||
private ItemStack slots[];
|
||||
|
||||
public int progress = 0;
|
||||
public long power = 0;
|
||||
public final static int maxProgress = 200;
|
||||
public final static long maxPower = 50000;
|
||||
public int item;
|
||||
public int meta;
|
||||
boolean isRetracting = false;
|
||||
|
||||
private String customName;
|
||||
|
||||
public TileEntityMachineEPress() {
|
||||
slots = new ItemStack[4];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return slots.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return slots[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
slots[i] = itemStack;
|
||||
if(itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomInventoryName() ? this.customName : "container.epress";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
this.customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
|
||||
if(stack.getItem() instanceof ItemBlades && i == 1)
|
||||
return true;
|
||||
|
||||
if(TileEntityFurnace.getItemBurnTime(stack) > 0 && i == 0)
|
||||
return true;
|
||||
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
if(slots[i].stackSize <= j)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
}
|
||||
ItemStack itemStack1 = slots[i].splitStack(j);
|
||||
if (slots[i].stackSize == 0)
|
||||
{
|
||||
slots[i] = null;
|
||||
}
|
||||
|
||||
return itemStack1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
NBTTagList list = nbt.getTagList("items", 10);
|
||||
|
||||
progress = nbt.getInteger("progress");
|
||||
power = nbt.getInteger("power");
|
||||
isRetracting = nbt.getBoolean("ret");
|
||||
|
||||
slots = new ItemStack[getSizeInventory()];
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
|
||||
byte b0 = nbt1.getByte("slot");
|
||||
if(b0 >= 0 && b0 < slots.length)
|
||||
{
|
||||
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
nbt.setInteger("progress", progress);
|
||||
nbt.setLong("power", power);
|
||||
nbt.setBoolean("ret", isRetracting);
|
||||
|
||||
for(int i = 0; i < slots.length; i++)
|
||||
{
|
||||
if(slots[i] != null)
|
||||
{
|
||||
NBTTagCompound nbt1 = new NBTTagCompound();
|
||||
nbt1.setByte("slot", (byte)i);
|
||||
slots[i].writeToNBT(nbt1);
|
||||
list.appendTag(nbt1);
|
||||
}
|
||||
}
|
||||
nbt.setTag("items", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return side == 0 ? new int[] { 3 } : new int[]{ 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemStack, int j) {
|
||||
return this.isItemValidForSlot(i, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
|
||||
return i == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||
|
||||
if(power >= 100) {
|
||||
|
||||
int speed = 25;
|
||||
|
||||
if(slots[1] != null && slots[2] != null) {
|
||||
ItemStack stack = MachineRecipes.getPressResult(slots[2].copy(), slots[1].copy());
|
||||
if(stack != null &&
|
||||
(slots[3] == null ||
|
||||
(slots[3].getItem() == stack.getItem() &&
|
||||
slots[3].stackSize + stack.stackSize <= slots[3].getMaxStackSize()))) {
|
||||
|
||||
power -= 100;
|
||||
|
||||
if(progress >= maxProgress) {
|
||||
|
||||
isRetracting = true;
|
||||
|
||||
if(slots[3] == null)
|
||||
slots[3] = stack.copy();
|
||||
else
|
||||
slots[3].stackSize += stack.stackSize;
|
||||
|
||||
slots[2].stackSize--;
|
||||
if(slots[2].stackSize <= 0)
|
||||
slots[2] = null;
|
||||
|
||||
slots[1].setItemDamage(slots[1].getItemDamage() + 1);
|
||||
if(slots[1].getItemDamage() >= slots[1].getMaxDamage())
|
||||
slots[1] = null;
|
||||
|
||||
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.pressOperate", 1.5F, 1.0F);
|
||||
}
|
||||
|
||||
if(!isRetracting)
|
||||
progress += speed;
|
||||
|
||||
} else {
|
||||
isRetracting = true;
|
||||
}
|
||||
} else {
|
||||
isRetracting = true;
|
||||
}
|
||||
|
||||
if(isRetracting)
|
||||
progress -= speed;
|
||||
} else {
|
||||
isRetracting = true;
|
||||
}
|
||||
|
||||
if(progress <= 0) {
|
||||
isRetracting = false;
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
PacketDispatcher.wrapper.sendToAll(new TEPressPacket(xCoord, yCoord, zCoord, slots[2], progress));
|
||||
PacketDispatcher.wrapper.sendToAll(new AuxElectricityPacket(xCoord, yCoord, zCoord, power));
|
||||
}
|
||||
}
|
||||
|
||||
public long getPowerScaled(int i) {
|
||||
return (power * i) / maxPower;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int i) {
|
||||
return (progress * i) / maxProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return TileEntity.INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long i) {
|
||||
power = i;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return maxPower;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.MachineRecipes;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.special.ItemBattery;
|
||||
import com.hbm.items.special.ItemBlades;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.TEPressPacket;
|
||||
@ -118,7 +119,14 @@ public class TileEntityMachinePress extends TileEntity implements ISidedInventor
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
return false;
|
||||
|
||||
if(stack.getItem() instanceof ItemBlades && i == 1)
|
||||
return true;
|
||||
|
||||
if(TileEntityFurnace.getItemBurnTime(stack) > 0 && i == 0)
|
||||
return true;
|
||||
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,9 +200,9 @@ public class TileEntityMachinePress extends TileEntity implements ISidedInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_)
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return new int[] {0, 1, 2, 3};
|
||||
return side == 0 ? new int[] { 3 } : new int[]{ 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -204,7 +212,7 @@ public class TileEntityMachinePress extends TileEntity implements ISidedInventor
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
|
||||
return false;
|
||||
return i == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user