Permalink
Browse files

Improved the functionality, model, and interface of the repulsion gen…

…erator.
  • Loading branch information...
Ri5ux committed Dec 18, 2017
1 parent f06bbee commit de106e09bf0051cd4c820fe37c5b10415e2ac1d3
@@ -4,6 +4,8 @@
import org.avp.client.gui.GuiBlastdoor;
import org.avp.client.gui.GuiLocker;
import org.avp.client.gui.GuiModSettings;
import org.avp.client.gui.GuiNetworkRack;
import org.avp.client.gui.GuiRepulsionGenerator;
import org.avp.client.gui.GuiSupplyCrate;
import org.avp.client.gui.GuiTurret;
import org.avp.client.gui.GuiWristbracer;
@@ -12,6 +14,8 @@
import org.avp.tile.TileEntityAssembler;
import org.avp.tile.TileEntityBlastdoor;
import org.avp.tile.TileEntityLocker;
import org.avp.tile.TileEntityNetworkRack;
import org.avp.tile.TileEntityRepulsionGenerator;
import org.avp.tile.TileEntitySupplyCrate;
import org.avp.tile.TileEntityTurret;
@@ -28,14 +32,16 @@
public class GuiHandler implements IGuiHandler, IInitEvent
{
public static final GuiHandler instance = new GuiHandler();
public final int GUI_ASSEMBLER = 0;
public final int GUI_TURRET = 1;
public final int GUI_WRISTBRACER = 2;
public final int GUI_LOCKER = 3;
public final int GUI_SUPPLYCRATE = 4;
public final int GUI_GRAPHICSSETTINGS = 5;
public final int GUI_BLASTDOOR_PSWD = 6;
public static final GuiHandler instance = new GuiHandler();
public final int GUI_ASSEMBLER = 0;
public final int GUI_TURRET = 1;
public final int GUI_WRISTBRACER = 2;
public final int GUI_LOCKER = 3;
public final int GUI_SUPPLYCRATE = 4;
public final int GUI_GRAPHICSSETTINGS = 5;
public final int GUI_BLASTDOOR_PSWD = 6;
public final int GUI_NETWORK_RACK = 7;
public final int GUI_REPULSION_GENERATOR = 8;
@Override
public void init(FMLInitializationEvent event)
@@ -76,6 +82,18 @@ public Object getServerGuiElement(int id, EntityPlayer player, World world, int
return supplyCrate.getNewContainer(player);
}
if (id == GUI_NETWORK_RACK)
{
TileEntityNetworkRack networkRack = (TileEntityNetworkRack) (world.getTileEntity(blockpos));
return networkRack.getNewContainer(player);
}
if (id == GUI_REPULSION_GENERATOR)
{
TileEntityRepulsionGenerator generator = (TileEntityRepulsionGenerator) (world.getTileEntity(blockpos));
return generator.getNewContainer(player);
}
return null;
}
@@ -124,6 +142,16 @@ public Object getClientGuiElement(int id, EntityPlayer player, World world, int
return new GuiBlastdoor((TileEntityBlastdoor) world.getTileEntity(blockpos));
}
if (id == GUI_NETWORK_RACK)
{
return new GuiNetworkRack(player, (TileEntityNetworkRack) world.getTileEntity(blockpos));
}
if (id == GUI_REPULSION_GENERATOR)
{
return new GuiRepulsionGenerator(player, (TileEntityRepulsionGenerator) world.getTileEntity(blockpos));
}
return null;
}
}
@@ -1,13 +1,20 @@
package org.avp.block;
import org.avp.AliensVsPredator;
import org.avp.tile.TileEntityRepulsionGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.internal.FMLNetworkHandler;
public class BlockGenerator extends Block
{
@@ -22,22 +29,44 @@ public TileEntity createTileEntity(World world, IBlockState state)
{
return new TileEntityRepulsionGenerator();
}
@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.INVISIBLE;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityRepulsionGenerator)
{
TileEntityRepulsionGenerator generator = (TileEntityRepulsionGenerator) tile;
showGeneratorGUI(playerIn, generator);
}
return super.onBlockActivated(world, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
}
public static void showGeneratorGUI(EntityPlayer player, TileEntityRepulsionGenerator generator)
{
if (!player.world.isRemote)
{
FMLNetworkHandler.openGui(player, AliensVsPredator.instance(), AliensVsPredator.interfaces().GUI_REPULSION_GENERATOR, player.world, generator.getPos().getX(), generator.getPos().getY(), generator.getPos().getZ());
}
}
}
@@ -303,6 +303,7 @@ public Models models()
public final Texture GUI_LOCKER = new Texture(AliensVsPredator.Properties.ID, "textures/gui/locker.png");
public final Texture GUI_ASSEMBLER = new Texture(AliensVsPredator.Properties.ID, "textures/gui/assembler.png");
public final Texture GUI_SUPPLYCRATE = new Texture(AliensVsPredator.Properties.ID, "textures/gui/supplycrate.png");
public final Texture GUI_REPULSION_GENERATOR = new Texture(AliensVsPredator.Properties.ID, "textures/gui/repulsion_generator.png");
public final Texture ICON_AMMO = new Texture(AliensVsPredator.Properties.ID, "textures/misc/icon-ammo.png");
public final Texture MOTIONTRACKER_BG = new Texture(AliensVsPredator.Properties.ID, "textures/misc/motiontracker/background.png");
public final Texture MOTIONTRACKER_FG = new Texture(AliensVsPredator.Properties.ID, "textures/misc/motiontracker/foreground.png");
@@ -0,0 +1,30 @@
package org.avp.client.gui;
import org.avp.AliensVsPredator;
import org.avp.tile.TileEntityRepulsionGenerator;
import com.arisux.mdx.lib.client.render.Draw;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
public class GuiRepulsionGenerator extends GuiContainer
{
private TileEntityRepulsionGenerator generator;
public GuiRepulsionGenerator(EntityPlayer player, TileEntityRepulsionGenerator generator)
{
super(generator.getNewContainer(player));
this.generator = generator;
this.xSize = 176;
this.ySize = 166;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
{
Draw.drawResource(AliensVsPredator.resources().GUI_REPULSION_GENERATOR, this.guiLeft, this.guiTop, 256, 256, 255F, 255F, 255F, 255F, 1F, 1F);
Draw.drawString(this.generator.getProposedSpeed() + "", this.guiLeft, this.guiTop + this.ySize + 10, 0xFFFF0000);
Draw.drawString(this.generator.getRotationSpeed() + "", this.guiLeft, this.guiTop + this.ySize + 20, 0xFFFF0000);
}
}
@@ -1,7 +1,11 @@
package org.avp.client.model.tile;
import org.avp.tile.TileEntityRepulsionGenerator;
import com.arisux.mdx.lib.client.Model;
import com.arisux.mdx.lib.game.Game;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelRenderer;
public class ModelRepulsionGenerator extends Model
@@ -129,10 +133,16 @@ public ModelRepulsionGenerator()
this.rotor.addChild(this.magnet6);
this.rotor.addChild(this.magnet2);
}
@Override
public void render(Object obj)
{
if (obj instanceof TileEntityRepulsionGenerator)
{
TileEntityRepulsionGenerator generator = (TileEntityRepulsionGenerator) obj;
this.rotor.rotateAngleY = ((Minecraft.getMinecraft().player.world.getWorldTime() % 360) + Game.partialTicks()) * (generator.getRotationSpeed());
}
this.wireframe2.render(DEFAULT_SCALE);
this.side7.render(DEFAULT_SCALE);
this.base.render(DEFAULT_SCALE);
@@ -21,8 +21,6 @@ public void renderTileEntityAt(TileEntityRepulsionGenerator tile, double posX, d
OpenGL.enable(GL_BLEND);
OpenGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OpenGL.translate(posX + 0.5F, posY + 1.5F, posZ + 0.5F);
OpenGL.rotate(tile.rotation * (-90F), 0F, 1F, 0F);
OpenGL.scale(1.0F, 1.0F, 1.0F);
OpenGL.rotate(180F, 1F, 0F, 0F);
AliensVsPredator.resources().models().REPULSION_GENERATOR.draw(tile);
OpenGL.popMatrix();
@@ -0,0 +1,108 @@
package org.avp.inventory;
import org.avp.tile.TileEntityRepulsionGenerator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerRepulsionGenerator extends Container
{
public EntityPlayer player;
public TileEntityRepulsionGenerator generator;
public ContainerRepulsionGenerator(EntityPlayer player, TileEntityRepulsionGenerator generator)
{
this.player = player;
this.generator = generator;
this.initialize();
}
public void initialize()
{
int offset = 53;
int slot = 0;
for (int i = 1; i >= 0; i--)
{
int y = offset * i;
addSlotToContainer(new Slot(this.generator.inventory, slot++, 26, y + 33));
addSlotToContainer(new Slot(this.generator.inventory, slot++, 60, y + 20));
addSlotToContainer(new Slot(this.generator.inventory, slot++, 94, y + 33));
addSlotToContainer(new Slot(this.generator.inventory, slot++, 60, y + 46));
addSlotToContainer(new Slot(this.generator.inventory, slot++, 134, y + 33));
}
for (byte s = 0; s < 9; s++)
{
addSlotToContainer(new Slot(player.inventory, s, 8 + (18 * s), 142));
}
}
@Override
public void onCraftMatrixChanged(IInventory iinventory)
{
super.onCraftMatrixChanged(iinventory);
this.generator.markDirty();
}
@Override
public void onContainerClosed(EntityPlayer player)
{
super.onContainerClosed(player);
this.generator.markDirty();
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int i)
{
Slot slot = getSlot(i);
if (slot != null && slot.getHasStack())
{
ItemStack stack = slot.getStack();
ItemStack result = stack.copy();
if (i >= 36)
{
if (!super.mergeItemStack(stack, 0, 36, false))
{
return null;
}
}
else if (i != 36 || !this.mergeItemStack(stack, 36, 36 + (this.generator.inventory.getSizeInventory() - 1), false))
{
return null;
}
else
{
return null;
}
if (stack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
slot.onPickupFromSlot(null, stack);
return result;
}
return null;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
}
Oops, something went wrong.

0 comments on commit de106e0

Please sign in to comment.