Permalink
Browse files

Added security tuners, blast doors can now be password protected. Sec…

…urity tuners can be used to automatically open doors.
  • Loading branch information...
Ri5ux committed Nov 5, 2017
1 parent e051859 commit 8674ee1db70f558550ce35dd6d601eb32e9a5027
@@ -1,6 +1,7 @@
package org.avp;
import org.avp.client.gui.GuiAssembler;
import org.avp.client.gui.GuiBlastdoor;
import org.avp.client.gui.GuiLocker;
import org.avp.client.gui.GuiModSettings;
import org.avp.client.gui.GuiSupplyCrate;
@@ -9,6 +10,7 @@
import org.avp.inventory.ContainerWristbracer;
import org.avp.item.ItemWristbracer;
import org.avp.tile.TileEntityAssembler;
import org.avp.tile.TileEntityBlastdoor;
import org.avp.tile.TileEntityLocker;
import org.avp.tile.TileEntitySupplyCrate;
import org.avp.tile.TileEntityTurret;
@@ -33,6 +35,7 @@
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;
@Override
public void init(FMLInitializationEvent event)
@@ -44,7 +47,7 @@ public void init(FMLInitializationEvent event)
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
BlockPos blockpos = new BlockPos(x, y, z);
if (id == GUI_ASSEMBLER)
return ((TileEntityAssembler) world.getTileEntity(blockpos)).getNewContainer(player);
@@ -80,7 +83,7 @@ public Object getServerGuiElement(int id, EntityPlayer player, World world, int
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
BlockPos blockpos = new BlockPos(x, y, z);
if (id == GUI_ASSEMBLER)
{
return new GuiAssembler(player.inventory, (TileEntityAssembler) world.getTileEntity(blockpos), world, x, y, z);
@@ -116,6 +119,11 @@ public Object getClientGuiElement(int id, EntityPlayer player, World world, int
return new GuiModSettings(Minecraft.getMinecraft().currentScreen);
}
if (id == GUI_BLASTDOOR_PSWD)
{
return new GuiBlastdoor((TileEntityBlastdoor) world.getTileEntity(blockpos));
}
return null;
}
}
@@ -85,7 +85,6 @@
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemSword;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class ItemHandler extends ItemRegistrationHandler<AliensVsPredator>
@@ -197,6 +196,7 @@
public Item itemMaintenanceJack = new ItemMaintenanceJack();
public Item blackGooBucket = new ItemBucket(AliensVsPredator.blocks().blackgoo);
public Item mistBucket = new ItemBucket(AliensVsPredator.blocks().mist);
public Item securityTuner = new HookedItem().setMaxStackSize(1);
public Item summonerDrone = new ItemEntitySummoner(EntityDrone.class);
public Item summonerAqua = new ItemEntitySummoner(EntityAqua.class);
@@ -410,5 +410,6 @@ public void pre(FMLPreInitializationEvent event)
register("phial.empty", itemPhialEmpty).setCreativeTab(AliensVsPredator.tabMain());
register("chargepack", itemChargePack).setCreativeTab(AliensVsPredator.tabMain());
register("tool.maintenancejack", itemMaintenanceJack).setCreativeTab(AliensVsPredator.tabMain());
register("tool.securitytuner", securityTuner).setCreativeTab(AliensVsPredator.tabMain());
}
}
@@ -13,6 +13,8 @@
import org.avp.packets.server.OrganismServerSync;
import org.avp.packets.server.PacketAddTuretTarget;
import org.avp.packets.server.PacketAssemble;
import org.avp.packets.server.PacketBlastdoorCommon;
import org.avp.packets.server.PacketBlastdoorCommon.PacketBlastdoorClient;
import org.avp.packets.server.PacketDamageEntity;
import org.avp.packets.server.PacketFireAPC;
import org.avp.packets.server.PacketFirearmSync;
@@ -67,6 +69,7 @@ public void init(FMLInitializationEvent event)
this.registerMessage(Side.SERVER, PacketWriteToDataDevice.class);
this.registerMessage(Side.SERVER, OrganismServerSync.class);
this.registerMessage(Side.SERVER, SpecialPlayerServerSync.class);
this.registerMessage(Side.SERVER, PacketBlastdoorCommon.class);
this.registerMessage(Side.CLIENT, PacketTurretTargetUpdate.class);
this.registerMessage(Side.CLIENT, PacketOvamorphContainsFacehugger.class);
this.registerMessage(Side.CLIENT, PacketAmmoUpdate.class);
@@ -79,6 +82,7 @@ public void init(FMLInitializationEvent event)
this.registerMessage(Side.CLIENT, PacketRotateRotatable.class);
this.registerMessage(Side.CLIENT, PacketSyncRF.class);
this.registerMessage(Side.CLIENT, PacketOpenGui.class);
this.registerMessage(Side.CLIENT, PacketBlastdoorClient.class);
}
@SuppressWarnings("unchecked")
@@ -1,6 +1,7 @@
package org.avp.block;
import org.avp.AliensVsPredator;
import org.avp.client.gui.GuiBlastdoor;
import org.avp.item.ItemMaintenanceJack;
import org.avp.tile.TileEntityBlastdoor;
@@ -23,6 +24,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
public class BlockBlastdoor extends Block
{
@@ -41,15 +43,35 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
if (tile != null && tile instanceof TileEntityBlastdoor)
{
TileEntityBlastdoor blastdoor = (TileEntityBlastdoor) tile;
TileEntityBlastdoor doorSubBlock = (TileEntityBlastdoor) tile;
TileEntityBlastdoor blastdoor = null;
if (blastdoor.isChild() && blastdoor.getParent() != null && canOpen(blastdoor.getParent(), player))
if (doorSubBlock.isChild() && doorSubBlock.getParent() != null)
{
this.onOpen(blastdoor.getParent(), world, player);
blastdoor = doorSubBlock.getParent();
}
else if (blastdoor.isParent() && canOpen(blastdoor, player))
else if (doorSubBlock.isParent())
{
this.onOpen(blastdoor, world, player);
blastdoor = doorSubBlock;
}
if (blastdoor != null && blastdoor.isOperational())
{
if (heldItem != null && heldItem.getItem() == AliensVsPredator.items().securityTuner)
{
if (blastdoor.playerHoldingRequiredSecurityTuner(player))
{
FMLCommonHandler.instance().showGuiScreen(new GuiBlastdoor(blastdoor, false));
}
}
else if (canOpen(blastdoor, player))
{
this.onOpen(blastdoor, world, player);
}
else if (blastdoor.isLocked())
{
FMLCommonHandler.instance().showGuiScreen(new GuiBlastdoor(blastdoor));
}
}
}
@@ -81,26 +103,27 @@ private void onOpen(TileEntityBlastdoor blastdoor, World world, EntityPlayer pla
}
else
{
blastdoor.playDoorOpenSound();
blastdoor.setOpen(!blastdoor.isOpen());
if (world.isRemote)
if (blastdoor != null)
{
final String value = (blastdoor.isOpen() ? "opened" : "closed");
Notifications.sendNotification(new Notification()
{
@Override
public String getMessage()
{
return "\u00A77 Blast door \u00A7a" + value + ".";
}
blastdoor.setOpen(!blastdoor.isOpen());
@Override
public int displayTimeout()
{
return 20;
}
});
if (world.isRemote)
{
final String value = (blastdoor.isOpen() ? "opened" : "closed");
Notifications.sendNotification(new Notification() {
@Override
public String getMessage()
{
return "\u00A77 Blast door \u00A7a" + value + ".";
}
@Override
public int displayTimeout()
{
return 20;
}
});
}
}
}
}
@@ -112,7 +135,7 @@ private boolean isOpenedByJack(TileEntityBlastdoor blastdoor, EntityPlayer playe
private boolean canOpen(TileEntityBlastdoor blastdoor, EntityPlayer player)
{
return blastdoor.isOperational() || isOpenedByJack(blastdoor, player);
return blastdoor.isOperational() && !blastdoor.isLocked() || isOpenedByJack(blastdoor, player);
}
@Override
@@ -125,7 +148,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
TileEntityBlastdoor blastdoor = (TileEntityBlastdoor) tile;
blastdoor.setDirection(Entities.getDirectionFacing(placer));
if (!blastdoor.setup(true))
{
world.setBlockToAir(pos);
@@ -172,7 +195,7 @@ public boolean hasTileEntity(IBlockState state)
{
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
{
@@ -206,13 +229,13 @@ public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullBlock(IBlockState state)
{
return true;
}
@Override
public boolean isFullCube(IBlockState state)
{
@@ -96,6 +96,7 @@
import org.avp.client.render.items.RenderItemRedstoneFluxGenerator;
import org.avp.client.render.items.RenderItemRepulsionGenerator;
import org.avp.client.render.items.RenderItemSatelliteDish;
import org.avp.client.render.items.RenderItemSevastopolBlastdoor;
import org.avp.client.render.items.RenderItemSkull;
import org.avp.client.render.items.RenderItemSniper;
import org.avp.client.render.items.RenderItemSolarPanel;
@@ -441,6 +442,7 @@ private void registerItemRenderers(ItemHandler items)
Renderers.registerItemRenderer(Item.getItemFromBlock(AliensVsPredator.blocks().gunLocker), new RenderItemGunLocker());
Renderers.registerItemRenderer(Item.getItemFromBlock(AliensVsPredator.blocks().medpod), new RenderItemMedpod());
Renderers.registerItemRenderer(Item.getItemFromBlock(AliensVsPredator.blocks().satelliteDish), new RenderItemSatelliteDish());
Renderers.registerItemRenderer(Item.getItemFromBlock(AliensVsPredator.blocks().sevastopolBlastDoor), new RenderItemSevastopolBlastdoor());
Renderers.registerItemRenderer(items.itemWristbracer, new RenderItemWristbracer());
Renderers.registerItemRenderer(items.itemStunBaton, new RenderItemStunBaton());
Renderers.registerItemRenderer(items.itemWristbracerBlades, new RenderItemWristbracerBlades());
Oops, something went wrong.

0 comments on commit 8674ee1

Please sign in to comment.