mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-10-25 20:22:19 +00:00
Add Dislocator Inhibitor (#60)
This commit is contained in:
1 parent
7bca3009b6
commit
bf5f0bcb5b
9 files changed
+219
-1
No files matched your search
@@ -56,6 +56,7 @@ import com.brandon3055.draconicevolution.common.tileentities.TileCKeyStone;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileChaosShard;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileContainerTemplate;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDislocatorInhibitor;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDissEnchanter;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser;
|
||||
@@ -262,6 +263,9 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(TileChaosShard.class, References.RESOURCESPREFIX + "TileChaosShard");
|
||||
GameRegistry
|
||||
.registerTileEntity(TileUpgradeModifier.class, References.RESOURCESPREFIX + "TileEnhancementModifier");
|
||||
GameRegistry.registerTileEntity(
|
||||
TileDislocatorInhibitor.class,
|
||||
References.RESOURCESPREFIX + "TileDislocatorInhibitor");
|
||||
if (DraconicEvolution.debug) {
|
||||
GameRegistry.registerTileEntity(TileTestBlock.class, References.RESOURCESPREFIX + "TileTestBlock");
|
||||
GameRegistry.registerTileEntity(
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.brandon3055.draconicevolution.common.blocks.SafetyFlame;
|
||||
import com.brandon3055.draconicevolution.common.blocks.TeleporterStand;
|
||||
import com.brandon3055.draconicevolution.common.blocks.TestBlock;
|
||||
import com.brandon3055.draconicevolution.common.blocks.XRayBlock;
|
||||
import com.brandon3055.draconicevolution.common.blocks.machine.DislocatorInhibitor;
|
||||
import com.brandon3055.draconicevolution.common.blocks.machine.DissEnchanter;
|
||||
import com.brandon3055.draconicevolution.common.blocks.machine.EnergyCrystal;
|
||||
import com.brandon3055.draconicevolution.common.blocks.machine.EnergyInfuser;
|
||||
@@ -90,6 +91,7 @@ public class ModBlocks {
|
||||
public static BlockDE reactorEnergyInjector;
|
||||
public static BlockDE chaosCrystal;
|
||||
public static BlockDE upgradeModifier;
|
||||
public static BlockDE dislocatorInhibitor;
|
||||
public static Block safetyFlame;
|
||||
public static Block chaosShardAtmos = new ChaosShardAtmos()
|
||||
.setBlockName(References.RESOURCESPREFIX + "chaosShardAtmos")
|
||||
@@ -133,6 +135,7 @@ public class ModBlocks {
|
||||
reactorEnergyInjector = new ReactorEnergyInjector();
|
||||
chaosCrystal = new ChaosCrystal();
|
||||
upgradeModifier = new UpgradeModifier();
|
||||
dislocatorInhibitor = new DislocatorInhibitor();
|
||||
|
||||
longRangeDislocator = new LongRangeDislocator();
|
||||
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks.machine;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.blocks.BlockDE;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDislocatorInhibitor;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class DislocatorInhibitor extends BlockDE implements ITileEntityProvider {
|
||||
|
||||
public DislocatorInhibitor() {
|
||||
this.setBlockName(Strings.dislocatorInhibitor);
|
||||
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
|
||||
this.setStepSound(soundTypeStone);
|
||||
ModBlocks.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockSolid(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int metadata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileDislocatorInhibitor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx,
|
||||
float pry, float prz) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile != null) {
|
||||
if (tile instanceof TileDislocatorInhibitor te) {
|
||||
if (!player.isSneaking()) te.increaseRange();
|
||||
else te.decreaseRange();
|
||||
|
||||
if (world.isRemote) player.addChatMessage(new ChatComponentText("Range: " + te.getRange()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, int x, int y, int z, Block blockBroken, int meta) {
|
||||
TileEntity tile = worldIn.getTileEntity(x, y, z);
|
||||
if (tile != null) {
|
||||
if (tile instanceof TileDislocatorInhibitor) {
|
||||
((TileDislocatorInhibitor) tile).unregister();
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(worldIn, x, y, z, blockBroken, meta);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "inhibitor_block");
|
||||
}
|
||||
}
|
||||
@@ -609,6 +609,17 @@ public class CraftingHandler {
|
||||
"ingotDraconium",
|
||||
'C',
|
||||
ModItems.draconicCore);
|
||||
addOre(
|
||||
ModBlocks.dislocatorInhibitor,
|
||||
"IBI",
|
||||
"BDB",
|
||||
"IBI",
|
||||
'I',
|
||||
"ingotIron",
|
||||
'B',
|
||||
Blocks.iron_bars,
|
||||
'D',
|
||||
new ItemStack(ModItems.magnet, 1, 0));
|
||||
|
||||
// machines adv
|
||||
ItemStack mobSoul = new ItemStack(ModItems.mobSoul);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.ItemDE;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDislocatorInhibitor;
|
||||
import com.brandon3055.draconicevolution.common.utills.IConfigurableItem;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import com.brandon3055.draconicevolution.integration.ModHelper;
|
||||
@@ -113,7 +114,8 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem {
|
||||
boolean playSound = false;
|
||||
|
||||
for (EntityItem item : items) {
|
||||
if (item.getEntityItem() == null || ModHelper.isAE2EntityFloatingItem(item)) {
|
||||
if (item.getEntityItem() == null || ModHelper.isAE2EntityFloatingItem(item)
|
||||
|| TileDislocatorInhibitor.isInInhibitorRange(world, item.posX, item.posY, item.posZ)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,4 +72,5 @@ public class Strings { // public static Block name
|
||||
public static final String draconiumFluxCapacitorName = "draconiumFluxCapacitor";
|
||||
public static final String energyCrystalName = "energyCrystal";
|
||||
public static final String wrenchName = "wrench";
|
||||
public static final String dislocatorInhibitor = "dislocatorInhibitor";
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileDislocatorInhibitor extends TileEntity {
|
||||
|
||||
public static final int MAXIMUM_RANGE = 16;
|
||||
public static final int MINIMUM_RANGE = 1;
|
||||
public static final HashMap<World, HashSet<TileDislocatorInhibitor>> inhibitors = new HashMap<>();
|
||||
|
||||
private boolean registered = false;
|
||||
private int range = 5;
|
||||
|
||||
public static boolean isInInhibitorRange(World world, double x, double y, double z) {
|
||||
HashSet<TileDislocatorInhibitor> list = inhibitors.get(world);
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
for (TileDislocatorInhibitor inhibitor : list) {
|
||||
if (inhibitor.isInRange(x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!registered) {
|
||||
HashSet<TileDislocatorInhibitor> map = inhibitors.computeIfAbsent(this.worldObj, k -> new HashSet<>());
|
||||
map.add(this);
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
if (inhibitors.containsKey(this.worldObj)) {
|
||||
HashSet<TileDislocatorInhibitor> list = inhibitors.get(this.worldObj);
|
||||
list.remove(this);
|
||||
if (list.isEmpty()) {
|
||||
inhibitors.remove(this.worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(int value) {
|
||||
if (value > MAXIMUM_RANGE) {
|
||||
value = MINIMUM_RANGE;
|
||||
}
|
||||
if (value < MINIMUM_RANGE) {
|
||||
value = MAXIMUM_RANGE;
|
||||
}
|
||||
this.range = value;
|
||||
}
|
||||
|
||||
public void increaseRange() {
|
||||
if (range < MAXIMUM_RANGE) {
|
||||
range++;
|
||||
}
|
||||
}
|
||||
|
||||
public void decreaseRange() {
|
||||
if (range > MINIMUM_RANGE) {
|
||||
range--;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInRange(double x, double y, double z) {
|
||||
return x >= this.xCoord - range && x <= this.xCoord + range + 1
|
||||
&& y >= this.yCoord - range
|
||||
&& y <= this.yCoord + range + 1
|
||||
&& z >= this.zCoord - range
|
||||
&& z <= this.zCoord + range + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
this.writeToNBT(tagCompound);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("Range", range);
|
||||
super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
range = compound.getInteger("Range");
|
||||
super.readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@ tile.draconicevolution:energyCrystal2.name=Energy Transceiver
|
||||
tile.draconicevolution:energyCrystal3.name=Advanced Energy Transceiver
|
||||
tile.draconicevolution:energyCrystal4.name=Wireless Energy Transceiver
|
||||
tile.draconicevolution:energyCrystal5.name=Advanced Wireless Transceiver
|
||||
tile.draconicevolution:dislocatorInhibitor.name=Dislocator Inhibitor
|
||||
|
||||
|
||||
//Item Information ----------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 877 B |
Reference in new issue
Block a user