fixes, burning out torches, remove some redstone

This commit is contained in:
Sen 2025-07-15 03:24:57 +02:00
parent 13b6a4e280
commit dabef4a3fd
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
94 changed files with 1902 additions and 4450 deletions

View file

@ -1,33 +0,0 @@
package common.block.artificial;
import common.block.Block;
import common.block.Material;
import common.util.BlockPos;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
public class BlockCompressedPowered extends Block
{
public BlockCompressedPowered(Material p_i46386_1_)
{
super(p_i46386_1_);
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return 15;
}
public boolean isMagnetic() {
return true;
}
}

View file

@ -9,6 +9,7 @@ import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.item.Item;
import common.item.block.ItemDoor;
import common.item.tool.ItemKey;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -55,17 +56,25 @@ public class BlockDoor extends Block implements Rotatable {
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyEnum<EnumHingePosition> HINGE = PropertyEnum.<EnumHingePosition>create("hinge", EnumHingePosition.class);
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyEnum<EnumDoorHalf> HALF = PropertyEnum.<EnumDoorHalf>create("half", EnumDoorHalf.class);
public static final List<BlockDoor> DOORS = Lists.newArrayList();
private ItemKey keyItem;
public BlockDoor(Material material) {
super(material);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(OPEN, false)
.withProperty(HINGE, EnumHingePosition.LEFT).withProperty(POWERED, false)
.withProperty(HALF, EnumDoorHalf.LOWER));
.withProperty(HINGE, EnumHingePosition.LEFT).withProperty(HALF, EnumDoorHalf.LOWER));
DOORS.add(this);
}
public void setKeyItem(ItemKey key) {
this.keyItem = key;
}
public ItemKey getKeyItem() {
return this.keyItem;
}
public boolean isOpaqueCube() {
return false;
@ -146,7 +155,7 @@ public class BlockDoor extends Block implements Rotatable {
}
public boolean onBlockActivated(World world, BlockPos pos, State state, EntityNPC player, Facing side, float hitX, float hitY, float hitZ) {
if(this.material == Material.SOLID)
if(this.keyItem != null && (player.getHeldItem() == null || player.getHeldItem().getItem() != this.keyItem))
return true;
BlockPos lower = state.getValue(HALF) == EnumDoorHalf.LOWER ? pos : pos.down();
BlockPos upper = state.getValue(HALF) == EnumDoorHalf.UPPER ? pos : pos.up();
@ -214,21 +223,6 @@ public class BlockDoor extends Block implements Rotatable {
this.dropBlockAsItem(world, pos, state, 0);
}
}
else {
boolean power = world.isBlockPowered(pos) || world.isBlockPowered(upper);
if((power || neighbor.canProvidePower()) && neighbor != this) {
world.setState(pos, state.withProperty(POWERED, power), 2);
world.setState(upper, top.withProperty(POWERED, power), 2);
if((power != state.getValue(OPEN)) || (power != top.getValue(OPEN))) {
world.setState(pos, state.withProperty(OPEN, power), 2);
world.setState(upper, top.withProperty(OPEN, power), 2);
world.markBlockRangeForRenderUpdate(pos, upper);
world.playAuxSFX(power ? 1003 : 1006, pos, 0);
}
}
}
}
}
@ -262,7 +256,7 @@ public class BlockDoor extends Block implements Rotatable {
}
protected Property[] getProperties() {
return new Property[] {HALF, FACING, OPEN, HINGE, POWERED};
return new Property[] {HALF, FACING, OPEN, HINGE};
}
private static ModelRotation getRotation(Facing rot, int offset) {
@ -290,10 +284,6 @@ public class BlockDoor extends Block implements Rotatable {
}
}
public Property<?>[] getIgnoredProperties() {
return new Property[] {POWERED};
}
protected Item getItemToRegister() {
return new ItemDoor(this);
}

View file

@ -25,17 +25,16 @@ import common.world.World;
public class BlockFenceGate extends Block implements Rotatable
{
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool IN_WALL = PropertyBool.create("in_wall");
private final String texture;
public BlockFenceGate(WoodType p_i46394_1_)
public BlockFenceGate(WoodType type)
{
super(Material.WOOD); // , p_i46394_1_.getMapColor());
this.setDefaultState(this.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
super(Material.WOOD);
this.setDefaultState(this.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
this.setTab(CheatTab.WOOD);
this.texture = p_i46394_1_.getName() + "_planks";
this.texture = type.getName() + "_planks";
}
/**
@ -110,7 +109,7 @@ public class BlockFenceGate extends Block implements Rotatable
*/
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false));
return this.getState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false));
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
@ -137,35 +136,6 @@ public class BlockFenceGate extends Block implements Rotatable
return true;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
boolean flag = worldIn.isBlockPowered(pos);
if (flag || neighborBlock.canProvidePower())
{
if (flag && !((Boolean)state.getValue(OPEN)).booleanValue() && !((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.setState(pos, state.withProperty(OPEN, Boolean.valueOf(true)).withProperty(POWERED, Boolean.valueOf(true)), 2);
worldIn.playAuxSFX(1003, pos, 0);
}
else if (!flag && ((Boolean)state.getValue(OPEN)).booleanValue() && ((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.setState(pos, state.withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)), 2);
worldIn.playAuxSFX(1006, pos, 0);
}
else if (flag != ((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)), 2);
}
}
}
}
public boolean shouldSideBeRendered(IWorldAccess worldIn, BlockPos pos, Facing side)
{
return true;
@ -173,7 +143,7 @@ public class BlockFenceGate extends Block implements Rotatable
protected Property[] getProperties()
{
return new Property[] {FACING, OPEN, POWERED, IN_WALL};
return new Property[] {FACING, OPEN, IN_WALL};
}
public Transforms getTransform() {
@ -377,10 +347,6 @@ public class BlockFenceGate extends Block implements Rotatable
.rotate(ModelRotation.getNorthRot(state.getValue(FACING).getOpposite()));
}
public Property<?>[] getIgnoredProperties() {
return new Property[] {POWERED};
}
public Property[] getUnsavedProperties() {
return new Property[] {IN_WALL};
}

View file

@ -0,0 +1,16 @@
package common.block.artificial;
import common.block.Block;
import common.block.Material;
public class BlockMagnetic extends Block
{
public BlockMagnetic(Material material)
{
super(material);
}
public boolean isMagnetic() {
return true;
}
}

View file

@ -5,8 +5,8 @@ import common.block.Rotatable;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.item.CheatTab;
import common.item.tool.ItemKey;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -30,6 +30,8 @@ public class BlockTrapDoor extends Block implements Rotatable
{
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyEnum<BlockTrapDoor.DoorHalf> HALF = PropertyEnum.<BlockTrapDoor.DoorHalf>create("half", BlockTrapDoor.DoorHalf.class);
private ItemKey keyItem;
public BlockTrapDoor(Material materialIn)
{
@ -40,6 +42,14 @@ public class BlockTrapDoor extends Block implements Rotatable
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
this.setTab(materialIn == Material.WOOD ? CheatTab.WOOD : CheatTab.TECHNOLOGY);
}
public void setKeyItem(ItemKey key) {
this.keyItem = key;
}
public ItemKey getKeyItem() {
return this.keyItem;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
@ -128,51 +138,14 @@ public class BlockTrapDoor extends Block implements Rotatable
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC player, Facing side, float hitX, float hitY, float hitZ)
{
if (this.material == Material.SOLID)
{
return true;
}
else
{
state = state.cycleProperty(OPEN);
worldIn.setState(pos, state, 2);
worldIn.playAuxSFX(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
return true;
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
BlockPos blockpos = pos.offset(((Facing)state.getValue(FACING)).getOpposite());
if (!isValidSupportBlock(worldIn.getState(blockpos).getBlock()))
{
worldIn.setBlockToAir(pos);
this.dropBlockAsItem(worldIn, pos, state, 0);
}
else
{
boolean flag = worldIn.isBlockPowered(pos);
if (flag || neighborBlock.canProvidePower())
{
boolean flag1 = ((Boolean)state.getValue(OPEN)).booleanValue();
if (flag1 != flag)
{
worldIn.setState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
worldIn.playAuxSFX(flag ? 1003 : 1006, pos, 0);
}
}
}
}
if(this.keyItem != null && (player.getHeldItem() == null || player.getHeldItem().getItem() != this.keyItem))
return true;
state = state.cycleProperty(OPEN);
worldIn.setState(pos, state, 2);
worldIn.playAuxSFX(player, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
return true;
}
/**
@ -197,61 +170,14 @@ public class BlockTrapDoor extends Block implements Rotatable
iblockstate = iblockstate.withProperty(FACING, facing).withProperty(OPEN, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(HALF, hitY > 0.5F ? BlockTrapDoor.DoorHalf.TOP : BlockTrapDoor.DoorHalf.BOTTOM);
}
else {
iblockstate = iblockstate.withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(HALF, facing == Facing.DOWN ? BlockTrapDoor.DoorHalf.TOP : BlockTrapDoor.DoorHalf.BOTTOM);
}
return iblockstate;
}
/**
* Check whether this Block can be placed on the given side
*/
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, Facing side)
{
return !side.getAxis().isVertical() && isValidSupportBlock(worldIn.getState(pos.offset(side.getOpposite())).getBlock());
}
protected static Facing getFacing(int meta)
{
switch (meta & 3)
{
case 0:
return Facing.NORTH;
case 1:
return Facing.SOUTH;
case 2:
return Facing.WEST;
case 3:
default:
return Facing.EAST;
}
}
protected static int getMetaForFacing(Facing facing)
{
switch (facing)
{
case NORTH:
return 0;
case SOUTH:
return 1;
case WEST:
return 2;
case EAST:
default:
return 3;
}
}
private static boolean isValidSupportBlock(Block blockIn)
{
return blockIn.getMaterial().isOpaque() && blockIn.isFullCube() || blockIn == Blocks.glass || blockIn instanceof BlockStainedGlass || blockIn == Blocks.glowstone || blockIn instanceof BlockSlab || blockIn instanceof BlockStairs;
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;

View file

@ -1,200 +0,0 @@
package common.block.natural;
import common.block.Block;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.util.ParticleType;
import common.world.AWorldClient;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRedstoneOre extends Block
{
private final boolean isOn;
public BlockRedstoneOre(boolean isOn)
{
super(Material.SOLID);
if (isOn)
{
this.setTickRandomly();
}
this.isOn = isOn;
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn, BlockPos pos)
{
return 30;
}
public void onBlockClicked(World worldIn, BlockPos pos, EntityNPC playerIn)
{
this.activate(worldIn, pos);
super.onBlockClicked(worldIn, pos, playerIn);
}
/**
* Triggered whenever an entity collides with this block (enters into the block)
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn)
{
this.activate(worldIn, pos);
super.onEntityCollidedWithBlock(worldIn, pos, entityIn);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
this.activate(worldIn, pos);
return super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
}
private void activate(World worldIn, BlockPos pos)
{
this.spawnParticles(worldIn, pos);
if (this == Blocks.redstone_ore)
{
worldIn.setState(pos, Blocks.lit_redstone_ore.getState());
}
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
if (this == Blocks.lit_redstone_ore)
{
worldIn.setState(pos, Blocks.redstone_ore.getState());
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.redstone;
}
/**
* Get the quantity dropped based on the given fortune level
*/
public int quantityDroppedWithBonus(int fortune, Random random)
{
return this.quantityDropped(random) + random.zrange(fortune + 1);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return random.range(4, 5);
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, State state, float chance, int fortune)
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
if (this.getItemDropped(state, worldIn.rand, fortune) != this.getItem())
{
int i = worldIn.rand.roll(5);
this.dropXpOnBlockBreak(worldIn, pos, i);
}
}
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
{
if (this.isOn)
{
this.spawnParticles(worldIn, pos);
}
}
private void spawnParticles(World worldIn, BlockPos pos)
{
Random random = worldIn.rand;
double d0 = 0.0625D;
for (int i = 0; i < 6; ++i)
{
double d1 = (double)((float)pos.getX() + random.floatv());
double d2 = (double)((float)pos.getY() + random.floatv());
double d3 = (double)((float)pos.getZ() + random.floatv());
if (i == 0 && !worldIn.getState(pos.up()).getBlock().isOpaqueCube())
{
d2 = (double)pos.getY() + d0 + 1.0D;
}
if (i == 1 && !worldIn.getState(pos.down()).getBlock().isOpaqueCube())
{
d2 = (double)pos.getY() - d0;
}
if (i == 2 && !worldIn.getState(pos.south()).getBlock().isOpaqueCube())
{
d3 = (double)pos.getZ() + d0 + 1.0D;
}
if (i == 3 && !worldIn.getState(pos.north()).getBlock().isOpaqueCube())
{
d3 = (double)pos.getZ() - d0;
}
if (i == 4 && !worldIn.getState(pos.east()).getBlock().isOpaqueCube())
{
d1 = (double)pos.getX() + d0 + 1.0D;
}
if (i == 5 && !worldIn.getState(pos.west()).getBlock().isOpaqueCube())
{
d1 = (double)pos.getX() - d0;
}
if (d1 < (double)pos.getX() || d1 > (double)(pos.getX() + 1) || d2 < 0.0D || d2 > (double)(pos.getY() + 1) || d3 < (double)pos.getZ() || d3 > (double)(pos.getZ() + 1))
{
worldIn.spawnParticle(ParticleType.DUST, d1, d2, d3, 0xff0000);
}
}
}
public ItemStack createStackedBlock(State state)
{
return new ItemStack(Items.redstone_ore);
}
public boolean isXrayVisible()
{
return true;
}
public boolean isMagnetic() {
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("redstone_ore").add().all();
}
protected Item getItemToRegister() {
return this.isOn ? null : super.getItemToRegister();
}
}

View file

@ -36,7 +36,7 @@ public abstract class BlockBasePressurePlate extends Block
protected void setBlockBoundsBasedOnState0(State state)
{
boolean flag = this.getRedstoneStrength(state) > 0;
boolean flag = this.getSignalStrength(state) > 0;
float f = 0.0625F;
if (flag)
@ -121,7 +121,7 @@ public abstract class BlockBasePressurePlate extends Block
{
// if (!worldIn.client)
// {
int i = this.getRedstoneStrength(state);
int i = this.getSignalStrength(state);
if (i > 0)
{
@ -137,7 +137,7 @@ public abstract class BlockBasePressurePlate extends Block
{
if (!worldIn.client)
{
int i = this.getRedstoneStrength(state);
int i = this.getSignalStrength(state);
if (i == 0)
{
@ -149,15 +149,15 @@ public abstract class BlockBasePressurePlate extends Block
/**
* Updates the pressure plate when stepped on
*/
protected void updateState(World worldIn, BlockPos pos, State state, int oldRedstoneStrength)
protected void updateState(World worldIn, BlockPos pos, State state, int oldSignal)
{
int i = this.computeRedstoneStrength(worldIn, pos);
boolean flag = oldRedstoneStrength > 0;
int i = this.computeSignalStrength(worldIn, pos);
boolean flag = oldSignal > 0;
boolean flag1 = i > 0;
if (oldRedstoneStrength != i)
if (oldSignal != i)
{
state = this.setRedstoneStrength(state, i);
state = this.setSignalStrength(state, i);
worldIn.setState(pos, state, 2);
this.updateNeighbors(worldIn, pos);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
@ -189,7 +189,7 @@ public abstract class BlockBasePressurePlate extends Block
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
if (this.getRedstoneStrength(state) > 0)
if (this.getSignalStrength(state) > 0)
{
this.updateNeighbors(worldIn, pos);
}
@ -208,12 +208,12 @@ public abstract class BlockBasePressurePlate extends Block
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return this.getRedstoneStrength(state);
return this.getSignalStrength(state);
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return side == Facing.UP ? this.getRedstoneStrength(state) : 0;
return side == Facing.UP ? this.getSignalStrength(state) : 0;
}
/**
@ -241,7 +241,7 @@ public abstract class BlockBasePressurePlate extends Block
}
public Model getModel(ModelProvider provider, String name, State state) {
if(this.getRedstoneStrength(state) > 0)
if(this.getSignalStrength(state) > 0)
return provider.getModel(this.getTexture())
.add(1, 0, 1, 15, 0.5f, 15)
.d().uv(1, 1, 15, 15)
@ -267,9 +267,9 @@ public abstract class BlockBasePressurePlate extends Block
public abstract String getTexture();
protected abstract int computeRedstoneStrength(World worldIn, BlockPos pos);
protected abstract int computeSignalStrength(World worldIn, BlockPos pos);
protected abstract int getRedstoneStrength(State state);
protected abstract int getSignalStrength(State state);
protected abstract State setRedstoneStrength(State state, int strength);
protected abstract State setSignalStrength(State state, int strength);
}

View file

@ -475,7 +475,7 @@ public class BlockBrewingStand extends BlockContainer
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
return Container.calcSignal(worldIn.getTileEntity(pos));
}
public BlockLayer getBlockLayer()

View file

@ -553,7 +553,6 @@ public class BlockCauldron extends Block
public void setWaterLevel(World worldIn, BlockPos pos, State state, int level)
{
worldIn.setState(pos, state.withProperty(LEVEL, Integer.valueOf(ExtMath.clampi(level, 0, 3))), 2);
worldIn.updateComparatorOutputLevel(pos, this);
}
/**

View file

@ -12,7 +12,6 @@ import common.entity.Entity;
import common.entity.animal.EntityCat;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.init.SoundEvent;
import common.inventory.Container;
import common.inventory.IInventory;
@ -21,6 +20,7 @@ import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemChest;
import common.item.tool.ItemKey;
import common.packet.SPacketSoundEffect;
import common.properties.Property;
import common.tileentity.TileEntity;
@ -157,7 +157,6 @@ public class BlockChest extends BlockContainer implements Rotatable
if (tileentity instanceof IInventory)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onBlockRemoved(worldIn, pos, state);
@ -176,7 +175,7 @@ public class BlockChest extends BlockContainer implements Rotatable
if (chest != null)
{
ItemStack stack = Vars.locking ? playerIn.getHeldItem() : null;
if(stack != null && stack.getItem() == Items.key) {
if(stack != null && stack.getItem() instanceof ItemKey) {
if(chest.getLockCode() != null) {
if(stack.hasDisplayName() && stack.getDisplayName().equals(chest.getLockCode())) {
chest.setLockCode(null);
@ -246,7 +245,7 @@ public class BlockChest extends BlockContainer implements Rotatable
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstoneFromInventory(this.getChest(worldIn, pos));
return Container.calcSignalFrom(this.getChest(worldIn, pos));
}
protected Property[] getProperties()

View file

@ -1,6 +1,5 @@
package common.block.tech;
import common.block.Block;
import common.block.BlockContainer;
import common.block.Directional;
import common.block.Material;
@ -15,7 +14,6 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.properties.PropertyBool;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDispenser;
@ -28,8 +26,6 @@ import common.world.AWorldServer;
public class BlockDispenser extends BlockContainer implements Directional
{
public static final PropertyBool TRIGGERED = PropertyBool.create("triggered");
protected Random rand = new Random();
public static void dispense(World world, double speed, Facing facing, Vec3 position, ItemStack stack)
@ -45,7 +41,7 @@ public class BlockDispenser extends BlockContainer implements Directional
public BlockDispenser()
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(TRIGGERED, Boolean.valueOf(false)));
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.TECHNOLOGY);
}
@ -94,7 +90,7 @@ public class BlockDispenser extends BlockContainer implements Directional
}
}
worldIn.setState(pos, state.withProperty(FACING, enumfacing).withProperty(TRIGGERED, Boolean.valueOf(false)), 2);
worldIn.setState(pos, state.withProperty(FACING, enumfacing), 2);
}
}
@ -126,67 +122,6 @@ public class BlockDispenser extends BlockContainer implements Directional
}
}
protected void dispense(World worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
worldIn.playAuxSFX(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if(itemstack != null) {
ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
tileentitydispenser.setInventorySlotContents(i, itemstack1.isEmpty() ? null : itemstack1);
}
}
}
}
protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(FACING);
ItemStack nstack = stack.getItem().dispenseStack(world, world.getTileEntity(pos), getDispensePosition(pos, facing), pos, facing, stack);
int id = stack.getItem().getDispenseSoundId();
if(id != 0)
world.playAuxSFX(id, pos, 0);
world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return nstack;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();
if (flag && !flag1)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn, pos));
worldIn.setState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
}
else if (!flag && flag1)
{
worldIn.setState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
}
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
// if (!worldIn.client)
// {
this.dispense(worldIn, pos);
// }
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
@ -201,7 +136,7 @@ public class BlockDispenser extends BlockContainer implements Directional
*/
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)).withProperty(TRIGGERED, Boolean.valueOf(false));
return this.getState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer));
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
@ -211,7 +146,6 @@ public class BlockDispenser extends BlockContainer implements Directional
if (tileentity instanceof TileEntityDispenser)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDispenser)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onBlockRemoved(worldIn, pos, state);
@ -225,11 +159,6 @@ public class BlockDispenser extends BlockContainer implements Directional
return new Vec3(d0, d1, d2);
}
public static Facing getFacing(int meta)
{
return Facing.getFront(meta & 7);
}
public boolean hasSignalProcessing()
{
return true;
@ -237,7 +166,7 @@ public class BlockDispenser extends BlockContainer implements Directional
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
return Container.calcSignal(worldIn.getTileEntity(pos));
}
/**
@ -258,7 +187,7 @@ public class BlockDispenser extends BlockContainer implements Directional
protected Property[] getProperties()
{
return new Property[] {FACING, TRIGGERED};
return new Property[] {FACING};
}
public boolean isMagnetic() {
@ -273,8 +202,4 @@ public class BlockDispenser extends BlockContainer implements Directional
return provider.getModel(name + "_front_horizontal").add().du("furnace_top").n()
.s("furnace_side").we("furnace_side").rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
public Property<?>[] getIgnoredProperties() {
return new Property[] {TRIGGERED};
}
}

View file

@ -1,88 +1,12 @@
package common.block.tech;
import common.inventory.IInventory;
import common.item.ItemStack;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDispenser;
import common.tileentity.TileEntityDropper;
import common.tileentity.TileEntityHopper;
import common.util.BlockPos;
import common.util.Facing;
import common.world.World;
public class BlockDropper extends BlockDispenser
{
protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(FACING);
dispense(world, 6.0, facing, getDispensePosition(pos, facing), stack.split(1));
world.playAuxSFX(1000, pos, 0);
world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return stack;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityDropper();
}
protected void dispense(World worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
worldIn.playAuxSFX(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if (itemstack != null)
{
Facing enumfacing = (Facing)worldIn.getState(pos).getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
if (itemstack1 != null && itemstack1.isEmpty())
{
itemstack1 = null;
}
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().split(1), enumfacing.getOpposite());
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (itemstack1.decrSize())
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
}

View file

@ -190,7 +190,6 @@ public class BlockFurnace extends BlockContainer implements Rotatable
if (tileentity instanceof TileEntityFurnace)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
}
@ -204,7 +203,7 @@ public class BlockFurnace extends BlockContainer implements Rotatable
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
return Container.calcSignal(worldIn.getTileEntity(pos));
}
public Item getItem(World worldIn, BlockPos pos)

View file

@ -1,7 +1,6 @@
package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.BlockContainer;
import common.block.DirectionalDown;
import common.block.Material;
@ -18,7 +17,6 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.properties.PropertyBool;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityHopper;
import common.util.BlockPos;
@ -83,12 +81,10 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
.e().uv(6, 12, 10, 16).noCull()
;
public static final PropertyBool ENABLED = PropertyBool.create("enabled");
public BlockHopper()
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN).withProperty(ENABLED, Boolean.valueOf(true)));
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN));
this.setTab(CheatTab.TECHNOLOGY);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@ -130,7 +126,7 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
enumfacing = Facing.DOWN;
}
return this.getState().withProperty(FACING, enumfacing).withProperty(ENABLED, Boolean.valueOf(true));
return this.getState().withProperty(FACING, enumfacing);
}
/**
@ -141,11 +137,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
return new TileEntityHopper();
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
this.updateState(worldIn, pos, state);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if (worldIn.client)
@ -166,24 +157,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
this.updateState(worldIn, pos, state);
}
private void updateState(World worldIn, BlockPos pos, State state)
{
boolean flag = !worldIn.isBlockPowered(pos);
if (flag != ((Boolean)state.getValue(ENABLED)).booleanValue())
{
worldIn.setState(pos, state.withProperty(ENABLED, Boolean.valueOf(flag)), 4);
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
@ -191,7 +164,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
if (tileentity instanceof TileEntityHopper)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityHopper)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onBlockRemoved(worldIn, pos, state);
@ -223,20 +195,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
return true;
}
public static Facing getFacing(int meta)
{
return Facing.getFront(meta & 7);
}
/**
* Get's the hopper's active status from the 8-bit of the metadata. Note that the metadata stores whether the block
* is powered, so this returns true when that bit is 0.
*/
public static boolean isEnabled(int meta)
{
return (meta & 8) != 8;
}
public boolean hasSignalProcessing()
{
return true;
@ -244,7 +202,7 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
return Container.calcSignal(worldIn.getTileEntity(pos));
}
public BlockLayer getBlockLayer()
@ -254,7 +212,7 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
protected Property[] getProperties()
{
return new Property[] {FACING, ENABLED};
return new Property[] {FACING};
}
public boolean isMagnetic() {
@ -314,10 +272,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
.e().uv(0, 8, 4, 12).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
public Property<?>[] getIgnoredProperties() {
return new Property[] {ENABLED};
}
protected Item getItemToRegister() {
return new ItemBlock(this, "hopper", true);

View file

@ -0,0 +1,125 @@
package common.block.tech;
import common.entity.npc.EntityNPC;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.util.ParticleType;
import common.vars.Vars;
import common.world.AWorldClient;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockLitTorch extends BlockTorch {
public static final PropertyInteger FUEL = PropertyInteger.create("fuel", 0, 7);
private BlockUnlitTorch unlit;
public BlockLitTorch(BlockUnlitTorch unlit) {
this.unlit = unlit;
unlit.setLitTorch(this);
this.setTab(CheatTab.TECHNOLOGY);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.UP).withProperty(FUEL, 7));
this.setTickRandomly();
}
public void extinguish(AWorldServer worldIn, BlockPos pos, State state, Random rand) {
worldIn.setState(pos, this.unlit.getState().withProperty(FACING, state.getValue(FACING)), 3);
worldIn.playSound(SoundEvent.FIZZ, (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F),
0.5F);
for(int i = 0; i < 5; ++i) {
double d0 = (double)pos.getX() + rand.doublev() * 0.6D + 0.2D;
double d1 = (double)pos.getY() + rand.doublev() * 0.6D + 0.2D;
double d2 = (double)pos.getZ() + rand.doublev() * 0.6D + 0.2D;
worldIn.spawnParticles(ParticleType.SMOKE, d0, d1, d2);
}
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand) {
if(Vars.torchBurnout > 0 && rand.chance(Vars.torchBurnout)) {
int fuel = state.getValue(FUEL);
if(fuel <= 0) {
this.extinguish(worldIn, pos, state, rand);
}
else {
worldIn.setState(pos, state.withProperty(FUEL, fuel - 1), 2);
}
}
}
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand) {
if(this.unlit.getParticleColor() == 0xffffffff) {
Facing enumfacing = (Facing)state.getValue(FACING);
double d0 = (double)pos.getX() + 0.5D;
double d1 = (double)pos.getY() + 0.7D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.22D;
double d4 = 0.27D;
if (enumfacing.getAxis().isHorizontal())
{
Facing enumfacing1 = enumfacing.getOpposite();
worldIn.spawnParticle(ParticleType.SMOKE, d0 + d4 * (double)enumfacing1.getFrontOffsetX(), d1 + d3, d2 + d4 * (double)enumfacing1.getFrontOffsetZ());
worldIn.spawnParticle(ParticleType.FLAME, d0 + d4 * (double)enumfacing1.getFrontOffsetX(), d1 + d3, d2 + d4 * (double)enumfacing1.getFrontOffsetZ());
}
else
{
worldIn.spawnParticle(ParticleType.SMOKE, d0, d1, d2);
worldIn.spawnParticle(ParticleType.FLAME, d0, d1, d2);
}
}
else {
double d0 = (double)pos.getX() + 0.5D + (rand.doublev() - 0.5D) * 0.2D;
double d1 = (double)pos.getY() + 0.7D + (rand.doublev() - 0.5D) * 0.2D;
double d2 = (double)pos.getZ() + 0.5D + (rand.doublev() - 0.5D) * 0.2D;
Facing enumfacing = (Facing)state.getValue(FACING);
if(enumfacing.getAxis().isHorizontal()) {
Facing enumfacing1 = enumfacing.getOpposite();
double d3 = 0.27D;
d0 += 0.27D * (double)enumfacing1.getFrontOffsetX();
d1 += 0.22D;
d2 += 0.27D * (double)enumfacing1.getFrontOffsetZ();
}
worldIn.spawnParticle(ParticleType.DUST, d0, d1, d2, this.unlit.getParticleColor());
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
if(!worldIn.client)
this.extinguish((AWorldServer)worldIn, pos, state, worldIn.rand);
return true;
}
protected Property[] getProperties() {
return new Property[] {FACING, FUEL};
}
public Property[] getIgnoredProperties() {
return new Property[] {FUEL};
}
protected Item getItemToRegister() {
return null;
}
public Item getItemDropped(State state, Random rand, int fortune) {
return this.unlit.getItem();
}
public Item getItem(World worldIn, BlockPos pos) {
return this.unlit.getItem();
}
public ItemStack createStackedBlock(State state) {
return new ItemStack(this.unlit.getItem());
}
}

View file

@ -57,7 +57,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof Device) {
InventoryHelper.dropInventoryItems(worldIn, pos, (Device)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onBlockRemoved(worldIn, pos, state);
worldIn.removeTileEntity(pos);
@ -68,7 +67,7 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
}
public int getSignal(World worldIn, BlockPos pos, int input) {
return Container.calcRedstone(worldIn.getTileEntity(pos));
return Container.calcSignal(worldIn.getTileEntity(pos));
}
public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam) {

View file

@ -15,7 +15,6 @@ import common.util.BlockPos;
import common.world.Explosion;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockNuke extends Block
{
@ -24,26 +23,6 @@ public class BlockNuke extends Block
super(Material.EXPLOSIVE);
this.setTab(CheatTab.TECHNOLOGY);
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockAdded(worldIn, pos, state);
if (worldIn.isBlockPowered(pos))
{
this.explode(worldIn, pos);
worldIn.setBlockToAir(pos);
}
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (worldIn.isBlockPowered(pos))
{
this.explode(worldIn, pos);
worldIn.setBlockToAir(pos);
}
}
public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn, State prevState)
{

View file

@ -333,32 +333,32 @@ public class BlockPistonBase extends Block implements Directional
private boolean shouldBeExtended(World worldIn, BlockPos pos, Facing facing)
{
for (Facing enumfacing : Facing.values())
{
if (enumfacing != facing && worldIn.isSidePowered(pos.offset(enumfacing), enumfacing))
{
return true;
}
}
// for (Facing enumfacing : Facing.values())
// {
// if (enumfacing != facing && worldIn.isSidePowered(pos.offset(enumfacing), enumfacing))
// {
// return true;
// }
// }
//
// if (worldIn.isSidePowered(pos, Facing.DOWN))
// {
// return true;
// }
// else
// {
// BlockPos blockpos = pos.up();
//
// for (Facing enumfacing1 : Facing.values())
// {
// if (enumfacing1 != Facing.DOWN && worldIn.isSidePowered(blockpos.offset(enumfacing1), enumfacing1))
// {
// return true;
// }
// }
if (worldIn.isSidePowered(pos, Facing.DOWN))
{
return true;
}
else
{
BlockPos blockpos = pos.up();
for (Facing enumfacing1 : Facing.values())
{
if (enumfacing1 != Facing.DOWN && worldIn.isSidePowered(blockpos.offset(enumfacing1), enumfacing1))
{
return true;
}
}
return false;
}
return false; // TODO: piston control
// }
}
/**

View file

@ -24,17 +24,17 @@ public class BlockPressurePlate extends BlockBasePressurePlate
this.sensitivity = sensitivityIn;
}
protected int getRedstoneStrength(State state)
protected int getSignalStrength(State state)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
}
protected State setRedstoneStrength(State state, int strength)
protected State setSignalStrength(State state, int strength)
{
return state.withProperty(POWERED, Boolean.valueOf(strength > 0));
}
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
protected int computeSignalStrength(World worldIn, BlockPos pos)
{
BoundingBox axisalignedbb = this.getSensitiveAABB(pos);
List <? extends Entity > list;

View file

@ -21,7 +21,7 @@ public class BlockPressurePlateWeighted extends BlockBasePressurePlate
this.field_150068_a = p_i46380_2_;
}
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
protected int computeSignalStrength(World worldIn, BlockPos pos)
{
int i = Math.min(worldIn.getEntitiesWithinAABB(Entity.class, this.getSensitiveAABB(pos)).size(), this.field_150068_a);
@ -36,12 +36,12 @@ public class BlockPressurePlateWeighted extends BlockBasePressurePlate
}
}
protected int getRedstoneStrength(State state)
protected int getSignalStrength(State state)
{
return ((Integer)state.getValue(POWER)).intValue();
}
protected State setRedstoneStrength(State state, int strength)
protected State setSignalStrength(State state, int strength)
{
return state.withProperty(POWER, Integer.valueOf(strength));
}

View file

@ -1,37 +1,710 @@
package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.Material;
import common.collect.Lists;
import common.init.Blocks;
import common.item.CheatTab;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.DirectionVec;
import common.util.Facing;
import common.util.HitPosition;
import common.util.Identifyable;
import common.util.Vec3;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRail extends BlockRailBase
public class BlockRail extends Block
{
public static final PropertyEnum<BlockRailBase.EnumRailDirection> SHAPE = PropertyEnum.<BlockRailBase.EnumRailDirection>create("shape", BlockRailBase.EnumRailDirection.class);
public static final PropertyEnum<BlockRail.EnumRailDirection> SHAPE = PropertyEnum.<BlockRail.EnumRailDirection>create("shape", BlockRail.EnumRailDirection.class);
public static boolean isRailBlock(World worldIn, BlockPos pos)
{
return isRailBlock(worldIn.getState(pos));
}
public static boolean isRailBlock(State state)
{
Block block = state.getBlock();
return block == Blocks.rail;
}
public BlockRail()
{
super(false);
this.setDefaultState(this.getBaseState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH));
super(Material.SMALL);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
this.setTab(CheatTab.TECHNOLOGY);
this.setFlatItemTexture();
this.setDefaultState(this.getBaseState().withProperty(SHAPE, BlockRail.EnumRailDirection.NORTH_SOUTH));
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
*/
public HitPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.collisionRayTrace(worldIn, pos, start, end);
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
State iblockstate = worldIn.getState(pos);
BlockRail.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() == this ? (BlockRail.EnumRailDirection)iblockstate.getValue(SHAPE) : null;
if (blockrailbase$enumraildirection != null && blockrailbase$enumraildirection.isAscending())
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F);
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
}
public boolean isFullCube()
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.isBlockSolid(pos.down());
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
if (!worldIn.client)
{
this.applyState(worldIn, pos, state, true);
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
BlockRail.EnumRailDirection blockrailbase$enumraildirection = (BlockRail.EnumRailDirection)state.getValue(SHAPE);
boolean flag = false;
if (!worldIn.isBlockSolid(pos.down()))
{
flag = true;
}
if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.ASCENDING_EAST && !worldIn.isBlockSolid(pos.east()))
{
flag = true;
}
else if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.ASCENDING_WEST && !worldIn.isBlockSolid(pos.west()))
{
flag = true;
}
else if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.ASCENDING_NORTH && !worldIn.isBlockSolid(pos.north()))
{
flag = true;
}
else if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.ASCENDING_SOUTH && !worldIn.isBlockSolid(pos.south()))
{
flag = true;
}
if (flag)
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
else
{
this.onNeighborChangedInternal(worldIn, pos, state, neighborBlock);
}
}
}
protected State applyState(World worldIn, BlockPos pos, State state, boolean force)
{
return worldIn.client ? state : (new BlockRail.Rail(worldIn, pos, state)).setDirection(false /* TODO: switching */, force).getBlockState();
}
public int getMobilityFlag()
{
return 0;
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockRemoved(worldIn, pos, state);
if (((BlockRail.EnumRailDirection)state.getValue(SHAPE)).isAscending())
{
worldIn.notifyNeighborsOfStateChange(pos.up(), this);
}
}
public boolean isMagnetic() {
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
EnumRailDirection dir = state.getValue(SHAPE);
switch(dir) {
case NORTH_SOUTH:
case EAST_WEST:
default:
return provider.getModel(name)
.add(0, 1, 0, 16, 1, 16)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.EAST_WEST ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
case NORTH_EAST:
case NORTH_WEST:
case SOUTH_EAST:
case SOUTH_WEST:
return provider.getModel(name + "_turned")
.add(0, 1, 0, 16, 1, 16)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.SOUTH_WEST ? ModelRotation.X0_Y90 : (dir == EnumRailDirection.NORTH_WEST ?
ModelRotation.X0_Y180 : (dir == EnumRailDirection.NORTH_EAST ? ModelRotation.X0_Y270 : ModelRotation.X0_Y0)));
case ASCENDING_NORTH:
case ASCENDING_EAST:
return provider.getModel(name)
.add(0, 9, 0, 16, 9, 16).rotate(8, 9, 8, Facing.Axis.X, 45, true)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.ASCENDING_EAST ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
case ASCENDING_SOUTH:
case ASCENDING_WEST:
return provider.getModel(name)
.add(0, 9, 0, 16, 9, 16).rotate(8, 9, 8, Facing.Axis.X, -45, true)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.ASCENDING_WEST ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
}
}
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (neighborBlock.canProvidePower() && (new BlockRailBase.Rail(worldIn, pos, state)).countAdjacentRails() == 3)
if ((new BlockRail.Rail(worldIn, pos, state)).countAdjacentRails() == 3)
{
this.func_176564_a(worldIn, pos, state, false);
this.applyState(worldIn, pos, state, false);
}
}
public Property<BlockRailBase.EnumRailDirection> getShapeProperty()
{
return SHAPE;
}
protected Property[] getProperties()
{
return new Property[] {SHAPE};
}
private static enum BaseShape {
STRAIGHT, ASCENDING, TURNED;
}
public static enum EnumRailDirection implements Identifyable, DirectionVec<EnumRailDirection>
{
NORTH_SOUTH("north_south", Facing.SOUTH, BaseShape.STRAIGHT),
EAST_WEST("east_west", Facing.EAST, BaseShape.STRAIGHT),
ASCENDING_EAST("ascending_east", Facing.EAST, BaseShape.ASCENDING),
ASCENDING_WEST("ascending_west", Facing.WEST, BaseShape.ASCENDING),
ASCENDING_NORTH("ascending_north", Facing.NORTH, BaseShape.ASCENDING),
ASCENDING_SOUTH("ascending_south", Facing.DOWN, BaseShape.ASCENDING),
SOUTH_EAST("south_east", Facing.EAST, BaseShape.TURNED),
SOUTH_WEST("south_west", Facing.SOUTH, BaseShape.TURNED),
NORTH_WEST("north_west", Facing.NORTH, BaseShape.TURNED),
NORTH_EAST("north_east", Facing.WEST, BaseShape.TURNED);
private final String name;
private final Facing facing;
private final BaseShape shape;
private EnumRailDirection(String name, Facing facing, BaseShape shape)
{
this.name = name;
this.facing = facing;
this.shape = shape;
}
public String toString()
{
return this.name;
}
public boolean isAscending()
{
return this == ASCENDING_NORTH || this == ASCENDING_EAST || this == ASCENDING_SOUTH || this == ASCENDING_WEST;
}
public String getName()
{
return this.name;
}
public Facing getFacing()
{
return this.facing;
}
public Facing getVector() {
return this.facing;
}
public boolean isAxis() {
return false;
}
public boolean canApply(EnumRailDirection dir) {
return this.shape == dir.shape;
}
}
public class Rail
{
private final World world;
private final BlockPos pos;
private final BlockRail block;
private State state;
private final List<BlockPos> field_150657_g = Lists.<BlockPos>newArrayList();
public Rail(World worldIn, BlockPos pos, State state)
{
this.world = worldIn;
this.pos = pos;
this.state = state;
this.block = (BlockRail)state.getBlock();
BlockRail.EnumRailDirection blockrailbase$enumraildirection = (BlockRail.EnumRailDirection)state.getValue(BlockRail.SHAPE);
this.func_180360_a(blockrailbase$enumraildirection);
}
private void func_180360_a(BlockRail.EnumRailDirection p_180360_1_)
{
this.field_150657_g.clear();
switch (p_180360_1_)
{
case NORTH_SOUTH:
this.field_150657_g.add(this.pos.north());
this.field_150657_g.add(this.pos.south());
break;
case EAST_WEST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.east());
break;
case ASCENDING_EAST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.east().up());
break;
case ASCENDING_WEST:
this.field_150657_g.add(this.pos.west().up());
this.field_150657_g.add(this.pos.east());
break;
case ASCENDING_NORTH:
this.field_150657_g.add(this.pos.north().up());
this.field_150657_g.add(this.pos.south());
break;
case ASCENDING_SOUTH:
this.field_150657_g.add(this.pos.north());
this.field_150657_g.add(this.pos.south().up());
break;
case SOUTH_EAST:
this.field_150657_g.add(this.pos.east());
this.field_150657_g.add(this.pos.south());
break;
case SOUTH_WEST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.south());
break;
case NORTH_WEST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.north());
break;
case NORTH_EAST:
this.field_150657_g.add(this.pos.east());
this.field_150657_g.add(this.pos.north());
}
}
private void func_150651_b()
{
for (int i = 0; i < this.field_150657_g.size(); ++i)
{
BlockRail.Rail blockrailbase$rail = this.findRailAt((BlockPos)this.field_150657_g.get(i));
if (blockrailbase$rail != null && blockrailbase$rail.func_150653_a(this))
{
this.field_150657_g.set(i, blockrailbase$rail.pos);
}
else
{
this.field_150657_g.remove(i--);
}
}
}
private boolean hasRailAt(BlockPos pos)
{
return BlockRail.isRailBlock(this.world, pos) || BlockRail.isRailBlock(this.world, pos.up()) || BlockRail.isRailBlock(this.world, pos.down());
}
private BlockRail.Rail findRailAt(BlockPos pos)
{
State iblockstate = this.world.getState(pos);
if (BlockRail.isRailBlock(iblockstate))
{
return BlockRail.this.new Rail(this.world, pos, iblockstate);
}
else
{
BlockPos lvt_2_1_ = pos.up();
iblockstate = this.world.getState(lvt_2_1_);
if (BlockRail.isRailBlock(iblockstate))
{
return BlockRail.this.new Rail(this.world, lvt_2_1_, iblockstate);
}
else
{
lvt_2_1_ = pos.down();
iblockstate = this.world.getState(lvt_2_1_);
return BlockRail.isRailBlock(iblockstate) ? BlockRail.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
}
}
}
private boolean func_150653_a(BlockRail.Rail p_150653_1_)
{
return this.func_180363_c(p_150653_1_.pos);
}
private boolean func_180363_c(BlockPos p_180363_1_)
{
for (int i = 0; i < this.field_150657_g.size(); ++i)
{
BlockPos blockpos = (BlockPos)this.field_150657_g.get(i);
if (blockpos.getX() == p_180363_1_.getX() && blockpos.getZ() == p_180363_1_.getZ())
{
return true;
}
}
return false;
}
protected int countAdjacentRails()
{
int i = 0;
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
if (this.hasRailAt(this.pos.offset(enumfacing)))
{
++i;
}
}
return i;
}
private boolean func_150649_b(BlockRail.Rail rail)
{
return this.func_150653_a(rail) || this.field_150657_g.size() != 2;
}
private void func_150645_c(BlockRail.Rail p_150645_1_)
{
this.field_150657_g.add(p_150645_1_.pos);
BlockPos blockpos = this.pos.north();
BlockPos blockpos1 = this.pos.south();
BlockPos blockpos2 = this.pos.west();
BlockPos blockpos3 = this.pos.east();
boolean flag = this.func_180363_c(blockpos);
boolean flag1 = this.func_180363_c(blockpos1);
boolean flag2 = this.func_180363_c(blockpos2);
boolean flag3 = this.func_180363_c(blockpos3);
BlockRail.EnumRailDirection blockrailbase$enumraildirection = null;
if (flag || flag1)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_SOUTH;
}
if (flag2 || flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.EAST_WEST;
}
if (flag1 && flag3 && !flag && !flag2)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_EAST;
}
if (flag1 && flag2 && !flag && !flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_WEST;
}
if (flag && flag2 && !flag1 && !flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_WEST;
}
if (flag && flag3 && !flag1 && !flag2)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_EAST;
}
if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.NORTH_SOUTH)
{
if (BlockRail.isRailBlock(this.world, blockpos.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_NORTH;
}
if (BlockRail.isRailBlock(this.world, blockpos1.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_SOUTH;
}
}
if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.EAST_WEST)
{
if (BlockRail.isRailBlock(this.world, blockpos3.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_EAST;
}
if (BlockRail.isRailBlock(this.world, blockpos2.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_WEST;
}
}
if (blockrailbase$enumraildirection == null)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_SOUTH;
}
this.state = this.state.withProperty(BlockRail.SHAPE, blockrailbase$enumraildirection);
this.world.setState(this.pos, this.state, 3);
}
private boolean func_180361_d(BlockPos p_180361_1_)
{
BlockRail.Rail blockrailbase$rail = this.findRailAt(p_180361_1_);
if (blockrailbase$rail == null)
{
return false;
}
else
{
blockrailbase$rail.func_150651_b();
return blockrailbase$rail.func_150649_b(this);
}
}
public BlockRail.Rail setDirection(boolean switched, boolean force)
{
BlockPos blockpos = this.pos.north();
BlockPos blockpos1 = this.pos.south();
BlockPos blockpos2 = this.pos.west();
BlockPos blockpos3 = this.pos.east();
boolean flag = this.func_180361_d(blockpos);
boolean flag1 = this.func_180361_d(blockpos1);
boolean flag2 = this.func_180361_d(blockpos2);
boolean flag3 = this.func_180361_d(blockpos3);
BlockRail.EnumRailDirection blockrailbase$enumraildirection = null;
if ((flag || flag1) && !flag2 && !flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_SOUTH;
}
if ((flag2 || flag3) && !flag && !flag1)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.EAST_WEST;
}
if (flag1 && flag3 && !flag && !flag2)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_EAST;
}
if (flag1 && flag2 && !flag && !flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_WEST;
}
if (flag && flag2 && !flag1 && !flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_WEST;
}
if (flag && flag3 && !flag1 && !flag2)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_EAST;
}
if (blockrailbase$enumraildirection == null)
{
if (flag || flag1)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_SOUTH;
}
if (flag2 || flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.EAST_WEST;
}
if (switched)
{
if (flag1 && flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_EAST;
}
if (flag2 && flag1)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_WEST;
}
if (flag3 && flag)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_EAST;
}
if (flag && flag2)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_WEST;
}
}
else
{
if (flag && flag2)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_WEST;
}
if (flag3 && flag)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_EAST;
}
if (flag2 && flag1)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_WEST;
}
if (flag1 && flag3)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.SOUTH_EAST;
}
}
}
if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.NORTH_SOUTH)
{
if (BlockRail.isRailBlock(this.world, blockpos.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_NORTH;
}
if (BlockRail.isRailBlock(this.world, blockpos1.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_SOUTH;
}
}
if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.EAST_WEST)
{
if (BlockRail.isRailBlock(this.world, blockpos3.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_EAST;
}
if (BlockRail.isRailBlock(this.world, blockpos2.up()))
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.ASCENDING_WEST;
}
}
if (blockrailbase$enumraildirection == null)
{
blockrailbase$enumraildirection = BlockRail.EnumRailDirection.NORTH_SOUTH;
}
this.func_180360_a(blockrailbase$enumraildirection);
this.state = this.state.withProperty(BlockRail.SHAPE, blockrailbase$enumraildirection);
if (force || this.world.getState(this.pos) != this.state)
{
this.world.setState(this.pos, this.state, 3);
for (int i = 0; i < this.field_150657_g.size(); ++i)
{
BlockRail.Rail blockrailbase$rail = this.findRailAt((BlockPos)this.field_150657_g.get(i));
if (blockrailbase$rail != null)
{
blockrailbase$rail.func_150651_b();
if (blockrailbase$rail.func_150649_b(this))
{
blockrailbase$rail.func_150645_c(this);
}
}
}
}
return this;
}
public State getBlockState()
{
return this.state;
}
}
}

View file

@ -1,724 +0,0 @@
package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.Material;
import common.collect.Lists;
import common.init.Blocks;
import common.item.CheatTab;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.DirectionVec;
import common.util.Facing;
import common.util.HitPosition;
import common.util.Identifyable;
import common.util.Vec3;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public abstract class BlockRailBase extends Block
{
protected final boolean isPowered;
public static boolean isRailBlock(World worldIn, BlockPos pos)
{
return isRailBlock(worldIn.getState(pos));
}
public static boolean isRailBlock(State state)
{
Block block = state.getBlock();
return block == Blocks.rail || block == Blocks.golden_rail || block == Blocks.detector_rail || block == Blocks.activator_rail;
}
public BlockRailBase(boolean isPowered)
{
super(Material.SMALL);
this.isPowered = isPowered;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
this.setTab(CheatTab.TECHNOLOGY);
this.setFlatItemTexture();
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
*/
public HitPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.collisionRayTrace(worldIn, pos, start, end);
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
State iblockstate = worldIn.getState(pos);
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() == this ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(this.getShapeProperty()) : null;
if (blockrailbase$enumraildirection != null && blockrailbase$enumraildirection.isAscending())
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F);
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
}
public boolean isFullCube()
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.isBlockSolid(pos.down());
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
if (!worldIn.client)
{
state = this.func_176564_a(worldIn, pos, state, true);
if (this.isPowered)
{
this.onNeighborBlockChange(worldIn, pos, state, this);
}
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(this.getShapeProperty());
boolean flag = false;
if (!worldIn.isBlockSolid(pos.down()))
{
flag = true;
}
if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !worldIn.isBlockSolid(pos.east()))
{
flag = true;
}
else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !worldIn.isBlockSolid(pos.west()))
{
flag = true;
}
else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !worldIn.isBlockSolid(pos.north()))
{
flag = true;
}
else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !worldIn.isBlockSolid(pos.south()))
{
flag = true;
}
if (flag)
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
else
{
this.onNeighborChangedInternal(worldIn, pos, state, neighborBlock);
}
}
}
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
}
protected State func_176564_a(World worldIn, BlockPos p_176564_2_, State p_176564_3_, boolean p_176564_4_)
{
return worldIn.client ? p_176564_3_ : (new BlockRailBase.Rail(worldIn, p_176564_2_, p_176564_3_)).func_180364_a(worldIn.isBlockPowered(p_176564_2_), p_176564_4_).getBlockState();
}
public int getMobilityFlag()
{
return 0;
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockRemoved(worldIn, pos, state);
if (((BlockRailBase.EnumRailDirection)state.getValue(this.getShapeProperty())).isAscending())
{
worldIn.notifyNeighborsOfStateChange(pos.up(), this);
}
if (this.isPowered)
{
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
}
}
public boolean isMagnetic() {
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
EnumRailDirection dir = state.getValue(this.getShapeProperty());
switch(dir) {
case NORTH_SOUTH:
case EAST_WEST:
default:
return provider.getModel(name)
.add(0, 1, 0, 16, 1, 16)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.EAST_WEST ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
case NORTH_EAST:
case NORTH_WEST:
case SOUTH_EAST:
case SOUTH_WEST:
return provider.getModel(name + "_turned")
.add(0, 1, 0, 16, 1, 16)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.SOUTH_WEST ? ModelRotation.X0_Y90 : (dir == EnumRailDirection.NORTH_WEST ?
ModelRotation.X0_Y180 : (dir == EnumRailDirection.NORTH_EAST ? ModelRotation.X0_Y270 : ModelRotation.X0_Y0)));
case ASCENDING_NORTH:
case ASCENDING_EAST:
return provider.getModel(name)
.add(0, 9, 0, 16, 9, 16).rotate(8, 9, 8, Facing.Axis.X, 45, true)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.ASCENDING_EAST ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
case ASCENDING_SOUTH:
case ASCENDING_WEST:
return provider.getModel(name)
.add(0, 9, 0, 16, 9, 16).rotate(8, 9, 8, Facing.Axis.X, -45, true)
.d().uv(0, 16, 16, 0).noCull()
.u().uv(0, 0, 16, 16).noCull()
.rotate(dir == EnumRailDirection.ASCENDING_WEST ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
}
}
public abstract Property<BlockRailBase.EnumRailDirection> getShapeProperty();
private static enum BaseShape {
STRAIGHT, ASCENDING, TURNED;
}
public static enum EnumRailDirection implements Identifyable, DirectionVec<EnumRailDirection>
{
NORTH_SOUTH("north_south", Facing.SOUTH, BaseShape.STRAIGHT),
EAST_WEST("east_west", Facing.EAST, BaseShape.STRAIGHT),
ASCENDING_EAST("ascending_east", Facing.EAST, BaseShape.ASCENDING),
ASCENDING_WEST("ascending_west", Facing.WEST, BaseShape.ASCENDING),
ASCENDING_NORTH("ascending_north", Facing.NORTH, BaseShape.ASCENDING),
ASCENDING_SOUTH("ascending_south", Facing.DOWN, BaseShape.ASCENDING),
SOUTH_EAST("south_east", Facing.EAST, BaseShape.TURNED),
SOUTH_WEST("south_west", Facing.SOUTH, BaseShape.TURNED),
NORTH_WEST("north_west", Facing.NORTH, BaseShape.TURNED),
NORTH_EAST("north_east", Facing.WEST, BaseShape.TURNED);
private final String name;
private final Facing facing;
private final BaseShape shape;
private EnumRailDirection(String name, Facing facing, BaseShape shape)
{
this.name = name;
this.facing = facing;
this.shape = shape;
}
public String toString()
{
return this.name;
}
public boolean isAscending()
{
return this == ASCENDING_NORTH || this == ASCENDING_EAST || this == ASCENDING_SOUTH || this == ASCENDING_WEST;
}
public String getName()
{
return this.name;
}
public Facing getFacing()
{
return this.facing;
}
public Facing getVector() {
return this.facing;
}
public boolean isAxis() {
return false;
}
public boolean canApply(EnumRailDirection dir) {
return this.shape == dir.shape;
}
}
public class Rail
{
private final World world;
private final BlockPos pos;
private final BlockRailBase block;
private State state;
private final boolean isPowered;
private final List<BlockPos> field_150657_g = Lists.<BlockPos>newArrayList();
public Rail(World worldIn, BlockPos pos, State state)
{
this.world = worldIn;
this.pos = pos;
this.state = state;
this.block = (BlockRailBase)state.getBlock();
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(BlockRailBase.this.getShapeProperty());
this.isPowered = this.block.isPowered;
this.func_180360_a(blockrailbase$enumraildirection);
}
private void func_180360_a(BlockRailBase.EnumRailDirection p_180360_1_)
{
this.field_150657_g.clear();
switch (p_180360_1_)
{
case NORTH_SOUTH:
this.field_150657_g.add(this.pos.north());
this.field_150657_g.add(this.pos.south());
break;
case EAST_WEST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.east());
break;
case ASCENDING_EAST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.east().up());
break;
case ASCENDING_WEST:
this.field_150657_g.add(this.pos.west().up());
this.field_150657_g.add(this.pos.east());
break;
case ASCENDING_NORTH:
this.field_150657_g.add(this.pos.north().up());
this.field_150657_g.add(this.pos.south());
break;
case ASCENDING_SOUTH:
this.field_150657_g.add(this.pos.north());
this.field_150657_g.add(this.pos.south().up());
break;
case SOUTH_EAST:
this.field_150657_g.add(this.pos.east());
this.field_150657_g.add(this.pos.south());
break;
case SOUTH_WEST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.south());
break;
case NORTH_WEST:
this.field_150657_g.add(this.pos.west());
this.field_150657_g.add(this.pos.north());
break;
case NORTH_EAST:
this.field_150657_g.add(this.pos.east());
this.field_150657_g.add(this.pos.north());
}
}
private void func_150651_b()
{
for (int i = 0; i < this.field_150657_g.size(); ++i)
{
BlockRailBase.Rail blockrailbase$rail = this.findRailAt((BlockPos)this.field_150657_g.get(i));
if (blockrailbase$rail != null && blockrailbase$rail.func_150653_a(this))
{
this.field_150657_g.set(i, blockrailbase$rail.pos);
}
else
{
this.field_150657_g.remove(i--);
}
}
}
private boolean hasRailAt(BlockPos pos)
{
return BlockRailBase.isRailBlock(this.world, pos) || BlockRailBase.isRailBlock(this.world, pos.up()) || BlockRailBase.isRailBlock(this.world, pos.down());
}
private BlockRailBase.Rail findRailAt(BlockPos pos)
{
State iblockstate = this.world.getState(pos);
if (BlockRailBase.isRailBlock(iblockstate))
{
return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
}
else
{
BlockPos lvt_2_1_ = pos.up();
iblockstate = this.world.getState(lvt_2_1_);
if (BlockRailBase.isRailBlock(iblockstate))
{
return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
}
else
{
lvt_2_1_ = pos.down();
iblockstate = this.world.getState(lvt_2_1_);
return BlockRailBase.isRailBlock(iblockstate) ? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
}
}
}
private boolean func_150653_a(BlockRailBase.Rail p_150653_1_)
{
return this.func_180363_c(p_150653_1_.pos);
}
private boolean func_180363_c(BlockPos p_180363_1_)
{
for (int i = 0; i < this.field_150657_g.size(); ++i)
{
BlockPos blockpos = (BlockPos)this.field_150657_g.get(i);
if (blockpos.getX() == p_180363_1_.getX() && blockpos.getZ() == p_180363_1_.getZ())
{
return true;
}
}
return false;
}
protected int countAdjacentRails()
{
int i = 0;
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
if (this.hasRailAt(this.pos.offset(enumfacing)))
{
++i;
}
}
return i;
}
private boolean func_150649_b(BlockRailBase.Rail rail)
{
return this.func_150653_a(rail) || this.field_150657_g.size() != 2;
}
private void func_150645_c(BlockRailBase.Rail p_150645_1_)
{
this.field_150657_g.add(p_150645_1_.pos);
BlockPos blockpos = this.pos.north();
BlockPos blockpos1 = this.pos.south();
BlockPos blockpos2 = this.pos.west();
BlockPos blockpos3 = this.pos.east();
boolean flag = this.func_180363_c(blockpos);
boolean flag1 = this.func_180363_c(blockpos1);
boolean flag2 = this.func_180363_c(blockpos2);
boolean flag3 = this.func_180363_c(blockpos3);
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = null;
if (flag || flag1)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
}
if (flag2 || flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
}
if (!this.isPowered)
{
if (flag1 && flag3 && !flag && !flag2)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
}
if (flag1 && flag2 && !flag && !flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
}
if (flag && flag2 && !flag1 && !flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
}
if (flag && flag3 && !flag1 && !flag2)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
}
}
if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
{
if (BlockRailBase.isRailBlock(this.world, blockpos.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_NORTH;
}
if (BlockRailBase.isRailBlock(this.world, blockpos1.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_SOUTH;
}
}
if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
{
if (BlockRailBase.isRailBlock(this.world, blockpos3.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_EAST;
}
if (BlockRailBase.isRailBlock(this.world, blockpos2.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_WEST;
}
}
if (blockrailbase$enumraildirection == null)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
}
this.state = this.state.withProperty(this.block.getShapeProperty(), blockrailbase$enumraildirection);
this.world.setState(this.pos, this.state, 3);
}
private boolean func_180361_d(BlockPos p_180361_1_)
{
BlockRailBase.Rail blockrailbase$rail = this.findRailAt(p_180361_1_);
if (blockrailbase$rail == null)
{
return false;
}
else
{
blockrailbase$rail.func_150651_b();
return blockrailbase$rail.func_150649_b(this);
}
}
public BlockRailBase.Rail func_180364_a(boolean p_180364_1_, boolean p_180364_2_)
{
BlockPos blockpos = this.pos.north();
BlockPos blockpos1 = this.pos.south();
BlockPos blockpos2 = this.pos.west();
BlockPos blockpos3 = this.pos.east();
boolean flag = this.func_180361_d(blockpos);
boolean flag1 = this.func_180361_d(blockpos1);
boolean flag2 = this.func_180361_d(blockpos2);
boolean flag3 = this.func_180361_d(blockpos3);
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = null;
if ((flag || flag1) && !flag2 && !flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
}
if ((flag2 || flag3) && !flag && !flag1)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
}
if (!this.isPowered)
{
if (flag1 && flag3 && !flag && !flag2)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
}
if (flag1 && flag2 && !flag && !flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
}
if (flag && flag2 && !flag1 && !flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
}
if (flag && flag3 && !flag1 && !flag2)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
}
}
if (blockrailbase$enumraildirection == null)
{
if (flag || flag1)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
}
if (flag2 || flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
}
if (!this.isPowered)
{
if (p_180364_1_)
{
if (flag1 && flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
}
if (flag2 && flag1)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
}
if (flag3 && flag)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
}
if (flag && flag2)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
}
}
else
{
if (flag && flag2)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
}
if (flag3 && flag)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
}
if (flag2 && flag1)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
}
if (flag1 && flag3)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
}
}
}
}
if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
{
if (BlockRailBase.isRailBlock(this.world, blockpos.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_NORTH;
}
if (BlockRailBase.isRailBlock(this.world, blockpos1.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_SOUTH;
}
}
if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
{
if (BlockRailBase.isRailBlock(this.world, blockpos3.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_EAST;
}
if (BlockRailBase.isRailBlock(this.world, blockpos2.up()))
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_WEST;
}
}
if (blockrailbase$enumraildirection == null)
{
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
}
this.func_180360_a(blockrailbase$enumraildirection);
this.state = this.state.withProperty(this.block.getShapeProperty(), blockrailbase$enumraildirection);
if (p_180364_2_ || this.world.getState(this.pos) != this.state)
{
this.world.setState(this.pos, this.state, 3);
for (int i = 0; i < this.field_150657_g.size(); ++i)
{
BlockRailBase.Rail blockrailbase$rail = this.findRailAt((BlockPos)this.field_150657_g.get(i));
if (blockrailbase$rail != null)
{
blockrailbase$rail.func_150651_b();
if (blockrailbase$rail.func_150649_b(this))
{
blockrailbase$rail.func_150645_c(this);
}
}
}
}
return this;
}
public State getBlockState()
{
return this.state;
}
}
}

View file

@ -1,187 +0,0 @@
package common.block.tech;
import java.util.List;
import java.util.function.Predicate;
import common.entity.Entity;
import common.entity.item.EntityCart;
import common.inventory.Container;
import common.inventory.IInventory;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRailDetector extends BlockRailBase
{
public static final PropertyEnum<BlockRailBase.EnumRailDirection> SHAPE = PropertyEnum.<BlockRailBase.EnumRailDirection>create("shape", EnumRailDirection.class, EnumRailDirection.NORTH_SOUTH, EnumRailDirection.EAST_WEST, EnumRailDirection.ASCENDING_EAST, EnumRailDirection.ASCENDING_WEST, EnumRailDirection.ASCENDING_NORTH, EnumRailDirection.ASCENDING_SOUTH);
public static final PropertyBool POWERED = PropertyBool.create("powered");
public BlockRailDetector()
{
super(true);
this.setDefaultState(this.getBaseState().withProperty(POWERED, Boolean.valueOf(false)).withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH));
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn, BlockPos pos)
{
return 20;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, State state, Entity entityIn)
{
if (!worldIn.client)
{
if (!((Boolean)state.getValue(POWERED)).booleanValue())
{
this.updatePoweredState(worldIn, pos, state);
}
}
}
/**
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
*/
public void randomTick(AWorldServer worldIn, BlockPos pos, State state, Random random)
{
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
if (/* !worldIn.client && */ ((Boolean)state.getValue(POWERED)).booleanValue())
{
this.updatePoweredState(worldIn, pos, state);
}
}
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return !((Boolean)state.getValue(POWERED)).booleanValue() ? 0 : (side == Facing.UP ? 15 : 0);
}
private void updatePoweredState(World worldIn, BlockPos pos, State state)
{
boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
boolean flag1 = false;
List<EntityCart> list = this.<EntityCart>findMinecarts(worldIn, pos, EntityCart.class, null);
if (!list.isEmpty())
{
flag1 = true;
}
if (flag1 && !flag)
{
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
}
if (!flag1 && flag)
{
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
}
if (flag1)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn, pos));
}
worldIn.updateComparatorOutputLevel(pos, this);
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockAdded(worldIn, pos, state);
this.updatePoweredState(worldIn, pos, state);
}
public Property<BlockRailBase.EnumRailDirection> getShapeProperty()
{
return SHAPE;
}
public boolean hasSignalProcessing()
{
return true;
}
public int getSignal(World worldIn, BlockPos pos, int input)
{
if (((Boolean)worldIn.getState(pos).getValue(POWERED)).booleanValue())
{
// List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, null);
//
// if (!list.isEmpty())
// {
// return ((EntityMinecartCommandBlock)list.get(0)).isPowered() ? 15 : 0;
// }
List<EntityCart> list1 = this.<EntityCart>findMinecarts(worldIn, pos, EntityCart.class, new Predicate<EntityCart>() {
public boolean test(EntityCart entity) {
return entity instanceof IInventory && entity.isEntityAlive();
}
});
if (!list1.isEmpty())
{
return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
}
}
return 0;
}
protected <T extends EntityCart> List<T> findMinecarts(World worldIn, BlockPos pos, Class<T> clazz, Predicate<EntityCart> filter)
{
BoundingBox axisalignedbb = this.getDectectionBox(pos);
return filter == null ? worldIn.getEntitiesWithinAABB(clazz, axisalignedbb) : worldIn.getEntitiesWithinAABB(clazz, axisalignedbb, filter);
}
private BoundingBox getDectectionBox(BlockPos pos)
{
float f = 0.2F;
return new BoundingBox((double)((float)pos.getX() + 0.2F), (double)pos.getY(), (double)((float)pos.getZ() + 0.2F), (double)((float)(pos.getX() + 1) - 0.2F), (double)((float)(pos.getY() + 1) - 0.2F), (double)((float)(pos.getZ() + 1) - 0.2F));
}
protected Property[] getProperties()
{
return new Property[] {SHAPE, POWERED};
}
public Model getModel(ModelProvider provider, String name, State state) {
return super.getModel(provider, name + (state.getValue(POWERED) ? "_powered" : ""), state);
}
}

View file

@ -1,174 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.util.BlockPos;
import common.world.State;
import common.world.World;
public class BlockRailPowered extends BlockRailBase
{
public static final PropertyEnum<BlockRailBase.EnumRailDirection> SHAPE = PropertyEnum.<BlockRailBase.EnumRailDirection>create("shape", EnumRailDirection.class, EnumRailDirection.NORTH_SOUTH, EnumRailDirection.EAST_WEST, EnumRailDirection.ASCENDING_EAST, EnumRailDirection.ASCENDING_WEST, EnumRailDirection.ASCENDING_NORTH, EnumRailDirection.ASCENDING_SOUTH);
public static final PropertyBool POWERED = PropertyBool.create("powered");
public BlockRailPowered()
{
super(true);
this.setDefaultState(this.getBaseState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH).withProperty(POWERED, Boolean.valueOf(false)));
}
protected boolean func_176566_a(World worldIn, BlockPos pos, State state, boolean p_176566_4_, int p_176566_5_)
{
if (p_176566_5_ >= 8)
{
return false;
}
else
{
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
boolean flag = true;
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(SHAPE);
switch (blockrailbase$enumraildirection)
{
case NORTH_SOUTH:
if (p_176566_4_)
{
++k;
}
else
{
--k;
}
break;
case EAST_WEST:
if (p_176566_4_)
{
--i;
}
else
{
++i;
}
break;
case ASCENDING_EAST:
if (p_176566_4_)
{
--i;
}
else
{
++i;
++j;
flag = false;
}
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
break;
case ASCENDING_WEST:
if (p_176566_4_)
{
--i;
++j;
flag = false;
}
else
{
++i;
}
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
break;
case ASCENDING_NORTH:
if (p_176566_4_)
{
++k;
}
else
{
--k;
++j;
flag = false;
}
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
break;
case ASCENDING_SOUTH:
if (p_176566_4_)
{
++k;
++j;
flag = false;
}
else
{
--k;
}
blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
}
return this.func_176567_a(worldIn, new BlockPos(i, j, k), p_176566_4_, p_176566_5_, blockrailbase$enumraildirection) ? true : flag && this.func_176567_a(worldIn, new BlockPos(i, j - 1, k), p_176566_4_, p_176566_5_, blockrailbase$enumraildirection);
}
}
protected boolean func_176567_a(World worldIn, BlockPos p_176567_2_, boolean p_176567_3_, int distance, BlockRailBase.EnumRailDirection p_176567_5_)
{
State iblockstate = worldIn.getState(p_176567_2_);
if (iblockstate.getBlock() != this)
{
return false;
}
else
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.getValue(SHAPE);
return p_176567_5_ != BlockRailBase.EnumRailDirection.EAST_WEST || blockrailbase$enumraildirection != BlockRailBase.EnumRailDirection.NORTH_SOUTH && blockrailbase$enumraildirection != BlockRailBase.EnumRailDirection.ASCENDING_NORTH && blockrailbase$enumraildirection != BlockRailBase.EnumRailDirection.ASCENDING_SOUTH ? (p_176567_5_ != BlockRailBase.EnumRailDirection.NORTH_SOUTH || blockrailbase$enumraildirection != BlockRailBase.EnumRailDirection.EAST_WEST && blockrailbase$enumraildirection != BlockRailBase.EnumRailDirection.ASCENDING_EAST && blockrailbase$enumraildirection != BlockRailBase.EnumRailDirection.ASCENDING_WEST ? (((Boolean)iblockstate.getValue(POWERED)).booleanValue() ? (worldIn.isBlockPowered(p_176567_2_) ? true : this.func_176566_a(worldIn, p_176567_2_, iblockstate, p_176567_3_, distance + 1)) : false) : false) : false;
}
}
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
boolean flag1 = worldIn.isBlockPowered(pos) || this.func_176566_a(worldIn, pos, state, true, 0) || this.func_176566_a(worldIn, pos, state, false, 0);
if (flag1 != flag)
{
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(flag1)), 3);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
if (((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).isAscending())
{
worldIn.notifyNeighborsOfStateChange(pos.up(), this);
}
}
}
public Property<BlockRailBase.EnumRailDirection> getShapeProperty()
{
return SHAPE;
}
protected Property[] getProperties()
{
return new Property[] {SHAPE, POWERED};
}
public Model getModel(ModelProvider provider, String name, State state) {
return super.getModel(provider, name + (state.getValue(POWERED) ? "_powered" : ""), state);
}
}

View file

@ -1,432 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.Items;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.block.ItemSmallBlock;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityComparator;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Identifyable;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITileEntityProvider
{
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyEnum<BlockRedstoneComparator.Mode> MODE = PropertyEnum.<BlockRedstoneComparator.Mode>create("mode", BlockRedstoneComparator.Mode.class);
public BlockRedstoneComparator(boolean powered)
{
super(powered);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, BlockRedstoneComparator.Mode.COMPARE));
this.hasTile = true;
}
// /**
// * Gets the localized name of this block. Used for the statistics page.
// */
// public String getLocalizedName()
// {
// return "Redstone-Komparator";
// }
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.comparator;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.comparator;
}
protected int getDelay(State state)
{
return 2;
}
protected State getPoweredState(State unpoweredState)
{
Boolean obool = (Boolean)unpoweredState.getValue(POWERED);
BlockRedstoneComparator.Mode blockredstonecomparator$mode = (BlockRedstoneComparator.Mode)unpoweredState.getValue(MODE);
Facing enumfacing = (Facing)unpoweredState.getValue(FACING);
return Blocks.powered_comparator.getState().withProperty(FACING, enumfacing).withProperty(POWERED, obool).withProperty(MODE, blockredstonecomparator$mode);
}
protected State getUnpoweredState(State poweredState)
{
Boolean obool = (Boolean)poweredState.getValue(POWERED);
BlockRedstoneComparator.Mode blockredstonecomparator$mode = (BlockRedstoneComparator.Mode)poweredState.getValue(MODE);
Facing enumfacing = (Facing)poweredState.getValue(FACING);
return Blocks.comparator.getState().withProperty(FACING, enumfacing).withProperty(POWERED, obool).withProperty(MODE, blockredstonecomparator$mode);
}
protected boolean isPowered(State state)
{
return this.isRepeaterPowered || ((Boolean)state.getValue(POWERED)).booleanValue();
}
protected int getActiveSignal(IWorldAccess worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity instanceof TileEntityComparator ? ((TileEntityComparator)tileentity).getOutputSignal() : 0;
}
private int calculateOutput(World worldIn, BlockPos pos, State state)
{
return state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? Math.max(this.calculateInputStrength(worldIn, pos, state) - this.getPowerOnSides(worldIn, pos, state), 0) : this.calculateInputStrength(worldIn, pos, state);
}
protected boolean shouldBePowered(World worldIn, BlockPos pos, State state)
{
int i = this.calculateInputStrength(worldIn, pos, state);
if (i >= 15)
{
return true;
}
else if (i == 0)
{
return false;
}
else
{
int j = this.getPowerOnSides(worldIn, pos, state);
return j == 0 ? true : i >= j;
}
}
protected int calculateInputStrength(World worldIn, BlockPos pos, State state)
{
int i = super.calculateInputStrength(worldIn, pos, state);
Facing enumfacing = (Facing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
Block block = worldIn.getState(blockpos).getBlock();
if (block.hasSignalProcessing())
{
i = block.getSignal(worldIn, blockpos, 0);
}
else if (i < 15 && block.isNormalCube())
{
blockpos = blockpos.offset(enumfacing);
block = worldIn.getState(blockpos).getBlock();
if (block.hasSignalProcessing())
{
i = block.getSignal(worldIn, blockpos, 0);
}
}
return i;
}
// private EntityFrame findItemFrame(World worldIn, final Facing facing, BlockPos pos)
// {
// List<EntityFrame> list = worldIn.<EntityFrame>getEntitiesWithinAABB(EntityFrame.class, new BoundingBox((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1)), new Predicate<Entity>()
// {
// public boolean test(Entity p_apply_1_)
// {
// return p_apply_1_ != null && p_apply_1_.getHorizontalFacing() == facing;
// }
// });
// return list.size() == 1 ? (EntityFrame)list.get(0) : null;
// }
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
// if (!playerIn.capabilities.allowEdit)
// {
// return false;
// }
// else
// {
state = state.cycleProperty(MODE);
worldIn.playSound(SoundEvent.CLICK, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.3F);
worldIn.setState(pos, state, 2);
this.onStateChange(worldIn, pos, state);
return true;
// }
}
protected void updateState(World worldIn, BlockPos pos, State state)
{
if (worldIn.client || !((AWorldServer)worldIn).isBlockTickPending(pos, this))
{
int i = this.calculateOutput(worldIn, pos, state);
TileEntity tileentity = worldIn.getTileEntity(pos);
int j = tileentity instanceof TileEntityComparator ? ((TileEntityComparator)tileentity).getOutputSignal() : 0;
if (i != j || this.isPowered(state) != this.shouldBePowered(worldIn, pos, state))
{
if (this.isFacingTowardsRepeater(worldIn, pos, state))
{
if(!worldIn.client)
((AWorldServer)worldIn).updateBlockTick(pos, this, 2, -1);
}
else
{
if(!worldIn.client)
((AWorldServer)worldIn).updateBlockTick(pos, this, 2, 0);
}
}
}
}
private void onStateChange(World worldIn, BlockPos pos, State state)
{
int i = this.calculateOutput(worldIn, pos, state);
TileEntity tileentity = worldIn.getTileEntity(pos);
int j = 0;
if (tileentity instanceof TileEntityComparator)
{
TileEntityComparator tileentitycomparator = (TileEntityComparator)tileentity;
j = tileentitycomparator.getOutputSignal();
tileentitycomparator.setOutputSignal(i);
}
if (j != i || state.getValue(MODE) == BlockRedstoneComparator.Mode.COMPARE)
{
boolean flag1 = this.shouldBePowered(worldIn, pos, state);
boolean flag = this.isPowered(state);
if (flag && !flag1)
{
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 2);
}
else if (!flag && flag1)
{
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 2);
}
this.notifyNeighbors(worldIn, pos, state);
}
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
if (this.isRepeaterPowered)
{
worldIn.setState(pos, this.getUnpoweredState(state).withProperty(POWERED, Boolean.valueOf(true)), 4);
}
this.onStateChange(worldIn, pos, state);
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockAdded(worldIn, pos, state);
worldIn.setTileEntity(pos, this.createNewTileEntity());
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockRemoved(worldIn, pos, state);
worldIn.removeTileEntity(pos);
this.notifyNeighbors(worldIn, pos, state);
}
/**
* Called on both Client and Server when World#addBlockEvent is called
*/
public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam)
{
super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityComparator();
}
protected Property[] getProperties()
{
return new Property[] {FACING, MODE, POWERED};
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, BlockRedstoneComparator.Mode.COMPARE);
}
public Model getModel(ModelProvider provider, String name, State state) {
return (state.getValue(POWERED) ? (state.getValue(MODE) == Mode.SUBTRACT ? provider.getModel("comparator_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(4, 7, 11, 6, 7, 13)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(4, 2, 10, 6, 8, 14)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(3, 2, 11, 7, 8, 13)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(10, 7, 11, 12, 7, 13)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(10, 2, 10, 12, 8, 14)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(9, 2, 11, 13, 8, 13)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(7, 5, 2, 9, 5, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 6, 5)
.w("redstone_torch").uv(6, 5, 10, 9).noCull()
.e("redstone_torch").uv(6, 5, 10, 9).noCull()
.add(6, 2, 2, 10, 6, 4)
.n("redstone_torch").uv(6, 5, 10, 9).noCull()
.s("redstone_torch").uv(6, 5, 10, 9).noCull() : provider.getModel("comparator_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(4, 7, 11, 6, 7, 13)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(4, 2, 10, 6, 8, 14)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(3, 2, 11, 7, 8, 13)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(10, 7, 11, 12, 7, 13)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(10, 2, 10, 12, 8, 14)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(9, 2, 11, 13, 8, 13)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(7, 2, 2, 9, 4, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 8).noCull())
: (state.getValue(MODE) == Mode.SUBTRACT ? provider.getModel("comparator_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(4, 2, 11, 6, 7, 13)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(10, 2, 11, 12, 7, 13)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(7, 5, 2, 9, 5, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 6, 5)
.w("redstone_torch").uv(6, 5, 10, 9).noCull()
.e("redstone_torch").uv(6, 5, 10, 9).noCull()
.add(6, 2, 2, 10, 6, 4)
.n("redstone_torch").uv(6, 5, 10, 9).noCull()
.s("redstone_torch").uv(6, 5, 10, 9).noCull() : provider.getModel("comparator_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(4, 2, 11, 6, 7, 13)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(10, 2, 11, 12, 7, 13)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(7, 2, 2, 9, 4, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()))
.rotate(ModelRotation.getNorthRot(state.getValue(FACING).getOpposite()));
}
protected Item getItemToRegister() {
return this.isRepeaterPowered ? null : new ItemSmallBlock(this).setDisplay("Redstone-Komparator").setTab(CheatTab.TECHNOLOGY);
}
public static enum Mode implements Identifyable
{
COMPARE("compare"),
SUBTRACT("subtract");
private final String name;
private Mode(String name)
{
this.name = name;
}
public String toString()
{
return this.name;
}
public String getName()
{
return this.name;
}
}
}

View file

@ -1,298 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.item.ItemStack;
import common.model.BlockLayer;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public abstract class BlockRedstoneDiode extends Block implements Rotatable
{
/** Tells whether the repeater is powered or not */
protected final boolean isRepeaterPowered;
public BlockRedstoneDiode(boolean powered)
{
super(Material.SMALL);
this.isRepeaterPowered = powered;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean isFullCube()
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.isBlockSolid(pos.down()) ? super.canPlaceBlockAt(worldIn, pos) : false;
}
public boolean canBlockStay(World worldIn, BlockPos pos)
{
return worldIn.isBlockSolid(pos.down());
}
/**
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
*/
public void randomTick(AWorldServer worldIn, BlockPos pos, State state, Random random)
{
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
if (!this.isLocked(worldIn, pos, state))
{
boolean flag = this.shouldBePowered(worldIn, pos, state);
if (this.isRepeaterPowered && !flag)
{
worldIn.setState(pos, this.getUnpoweredState(state), 2);
}
else if (!this.isRepeaterPowered)
{
worldIn.setState(pos, this.getPoweredState(state), 2);
if (!flag)
{
worldIn.updateBlockTick(pos, this.getPoweredState(state).getBlock(), this.getTickDelay(state), -1);
}
}
}
}
public boolean shouldSideBeRendered(IWorldAccess worldIn, BlockPos pos, Facing side)
{
return side.getAxis() != Facing.Axis.Y;
}
protected boolean isPowered(State state)
{
return this.isRepeaterPowered;
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return this.getWeakPower(worldIn, pos, state, side);
}
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return !this.isPowered(state) ? 0 : (state.getValue(FACING) == side ? this.getActiveSignal(worldIn, pos, state) : 0);
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (this.canBlockStay(worldIn, pos))
{
this.updateState(worldIn, pos, state);
}
else
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
for (Facing enumfacing : Facing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
}
protected void updateState(World worldIn, BlockPos pos, State state)
{
if (!this.isLocked(worldIn, pos, state))
{
boolean flag = this.shouldBePowered(worldIn, pos, state);
if ((this.isRepeaterPowered && !flag || !this.isRepeaterPowered && flag) && (worldIn.client || !((AWorldServer)worldIn).isBlockTickPending(pos, this)))
{
int i = -1;
if (this.isFacingTowardsRepeater(worldIn, pos, state))
{
i = -3;
}
else if (this.isRepeaterPowered)
{
i = -2;
}
if(!worldIn.client)
((AWorldServer)worldIn).updateBlockTick(pos, this, this.getDelay(state), i);
}
}
}
public boolean isLocked(IWorldAccess worldIn, BlockPos pos, State state)
{
return false;
}
protected boolean shouldBePowered(World worldIn, BlockPos pos, State state)
{
return this.calculateInputStrength(worldIn, pos, state) > 0;
}
protected int calculateInputStrength(World worldIn, BlockPos pos, State state)
{
Facing enumfacing = (Facing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
int i = worldIn.getRedstonePower(blockpos, enumfacing);
if (i >= 15)
{
return i;
}
else
{
State iblockstate = worldIn.getState(blockpos);
return Math.max(i, iblockstate.getBlock() == Blocks.redstone ? ((Integer)iblockstate.getValue(BlockRedstoneWire.POWER)).intValue() : 0);
}
}
protected int getPowerOnSides(IWorldAccess worldIn, BlockPos pos, State state)
{
Facing enumfacing = (Facing)state.getValue(FACING);
Facing enumfacing1 = enumfacing.rotateY();
Facing enumfacing2 = enumfacing.rotateYCCW();
return Math.max(this.getPowerOnSide(worldIn, pos.offset(enumfacing1), enumfacing1), this.getPowerOnSide(worldIn, pos.offset(enumfacing2), enumfacing2));
}
protected int getPowerOnSide(IWorldAccess worldIn, BlockPos pos, Facing side)
{
State iblockstate = worldIn.getState(pos);
Block block = iblockstate.getBlock();
return this.canPowerSide(block) ? (block == Blocks.redstone ? ((Integer)iblockstate.getValue(BlockRedstoneWire.POWER)).intValue() : iblockstate.getBlock().getStrongPower(worldIn, pos, iblockstate, side)) : 0;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
if (this.shouldBePowered(worldIn, pos, state))
{
worldIn.scheduleUpdate(pos, this, 1);
}
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
this.notifyNeighbors(worldIn, pos, state);
}
protected void notifyNeighbors(World worldIn, BlockPos pos, State state)
{
Facing enumfacing = (Facing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
worldIn.notifyBlockOfStateChange(blockpos, this);
worldIn.notifyNeighborsOfStateExcept(blockpos, this, enumfacing);
}
/**
* Called when a player destroys this Block
*/
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, State state)
{
if (this.isRepeaterPowered)
{
for (Facing enumfacing : Facing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
super.onBlockDestroyedByPlayer(worldIn, pos, state);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
protected boolean canPowerSide(Block blockIn)
{
return blockIn.canProvidePower();
}
protected int getActiveSignal(IWorldAccess worldIn, BlockPos pos, State state)
{
return 15;
}
public static boolean isRedstoneRepeaterBlockID(Block blockIn)
{
return Blocks.repeater.isAssociated(blockIn) || Blocks.comparator.isAssociated(blockIn);
}
public boolean isAssociated(Block other)
{
return other == this.getPoweredState(this.getState()).getBlock() || other == this.getUnpoweredState(this.getState()).getBlock();
}
public boolean isFacingTowardsRepeater(World worldIn, BlockPos pos, State state)
{
Facing enumfacing = ((Facing)state.getValue(FACING)).getOpposite();
BlockPos blockpos = pos.offset(enumfacing);
return isRedstoneRepeaterBlockID(worldIn.getState(blockpos).getBlock()) ? worldIn.getState(blockpos).getValue(FACING) != enumfacing : false;
}
protected int getTickDelay(State state)
{
return this.getDelay(state);
}
protected abstract int getDelay(State state);
protected abstract State getPoweredState(State unpoweredState);
protected abstract State getUnpoweredState(State poweredState);
public boolean isAssociatedBlock(Block other)
{
return this.isAssociated(other);
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
}
public boolean isMagnetic() {
return true;
}
}

View file

@ -1,99 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.Material;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.rng.Random;
import common.util.BlockPos;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRedstoneLight extends Block
{
private final boolean isOn;
public BlockRedstoneLight(boolean isOn)
{
super(Material.LOOSE);
this.isOn = isOn;
if (isOn)
{
this.setLightLevel(1.0F);
}
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
if (!worldIn.client)
{
if (this.isOn && !worldIn.isBlockPowered(pos))
{
worldIn.setState(pos, Blocks.redstone_lamp.getState(), 2);
}
else if (!this.isOn && worldIn.isBlockPowered(pos))
{
worldIn.setState(pos, Blocks.lit_redstone_lamp.getState(), 2);
}
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
if (this.isOn && !worldIn.isBlockPowered(pos))
{
worldIn.scheduleUpdate(pos, this, 4);
}
else if (!this.isOn && worldIn.isBlockPowered(pos))
{
worldIn.setState(pos, Blocks.lit_redstone_lamp.getState(), 2);
}
}
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
// if (!worldIn.client)
// {
if (this.isOn && !worldIn.isBlockPowered(pos))
{
worldIn.setState(pos, Blocks.redstone_lamp.getState(), 2);
}
// }
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.redstone_lamp;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.redstone_lamp;
}
public ItemStack createStackedBlock(State state)
{
return new ItemStack(Items.redstone_lamp);
}
public boolean isMagnetic() {
return true;
}
protected Item getItemToRegister() {
return this.isOn ? null : super.getItemToRegister();
}
}

View file

@ -1,562 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.block.ItemSmallBlock;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.util.ParticleType;
import common.world.IWorldAccess;
import common.world.AWorldClient;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRedstoneRepeater extends BlockRedstoneDiode
{
public static final PropertyBool LOCKED = PropertyBool.create("locked");
public static final PropertyInteger DELAY = PropertyInteger.create("delay", 1, 4);
public BlockRedstoneRepeater(boolean powered)
{
super(powered);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(DELAY, Integer.valueOf(1)).withProperty(LOCKED, Boolean.valueOf(false)));
}
// /**
// * Gets the localized name of this block. Used for the statistics page.
// */
// public String getLocalizedName()
// {
// return "Redstone-Verstärker";
// }
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public State getActualState(State state, IWorldAccess worldIn, BlockPos pos)
{
return state.withProperty(LOCKED, Boolean.valueOf(this.isLocked(worldIn, pos, state)));
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
// if (!playerIn.capabilities.allowEdit)
// {
// return false;
// }
// else
// {
worldIn.setState(pos, state.cycleProperty(DELAY), 3);
return true;
// }
}
protected int getDelay(State state)
{
return ((Integer)state.getValue(DELAY)).intValue() * 2;
}
protected State getPoweredState(State unpoweredState)
{
Integer integer = (Integer)unpoweredState.getValue(DELAY);
Boolean obool = (Boolean)unpoweredState.getValue(LOCKED);
Facing enumfacing = (Facing)unpoweredState.getValue(FACING);
return Blocks.powered_repeater.getState().withProperty(FACING, enumfacing).withProperty(DELAY, integer).withProperty(LOCKED, obool);
}
protected State getUnpoweredState(State poweredState)
{
Integer integer = (Integer)poweredState.getValue(DELAY);
Boolean obool = (Boolean)poweredState.getValue(LOCKED);
Facing enumfacing = (Facing)poweredState.getValue(FACING);
return Blocks.repeater.getState().withProperty(FACING, enumfacing).withProperty(DELAY, integer).withProperty(LOCKED, obool);
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.repeater;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.repeater;
}
public boolean isLocked(IWorldAccess worldIn, BlockPos pos, State state)
{
return this.getPowerOnSides(worldIn, pos, state) > 0;
}
protected boolean canPowerSide(Block blockIn)
{
return isRedstoneRepeaterBlockID(blockIn);
}
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
{
if (this.isRepeaterPowered)
{
Facing enumfacing = (Facing)state.getValue(FACING);
double d0 = (double)((float)pos.getX() + 0.5F) + (double)(rand.floatv() - 0.5F) * 0.2D;
double d1 = (double)((float)pos.getY() + 0.4F) + (double)(rand.floatv() - 0.5F) * 0.2D;
double d2 = (double)((float)pos.getZ() + 0.5F) + (double)(rand.floatv() - 0.5F) * 0.2D;
float f = -5.0F;
if (rand.chance())
{
f = (float)(((Integer)state.getValue(DELAY)).intValue() * 2 - 1);
}
f = f / 16.0F;
double d3 = (double)(f * (float)enumfacing.getFrontOffsetX());
double d4 = (double)(f * (float)enumfacing.getFrontOffsetZ());
worldIn.spawnParticle(ParticleType.DUST, d0 + d3, d1, d2 + d4, 0xff0000);
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockRemoved(worldIn, pos, state);
this.notifyNeighbors(worldIn, pos, state);
}
protected Property[] getProperties()
{
return new Property[] {FACING, DELAY, LOCKED};
}
private static Model getModelOff(int delay) {
switch(delay) {
case 1:
default:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 2, 6, 9, 7, 8)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
case 2:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 2, 8, 9, 7, 10)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
case 3:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 2, 10, 9, 7, 12)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
case 4:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 2, 12, 9, 7, 14)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
}
}
private static Model getModelOn(int delay) {
switch(delay) {
case 1:
default:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 7, 6, 9, 7, 8)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 5, 9, 8, 9)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 6, 10, 8, 8)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
case 2:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 7, 8, 9, 7, 10)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 7, 9, 8, 11)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 8, 10, 8, 10)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
case 3:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 7, 10, 9, 7, 12)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 9, 9, 8, 13)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 10, 10, 8, 12)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
case 4:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(7, 7, 12, 9, 7, 14)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 11, 9, 8, 15)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 12, 10, 8, 14)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
}
}
private static Model getModelOffLocked(int delay) {
switch(delay) {
case 1:
default:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 6, 14, 4, 8)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
case 2:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 8, 14, 4, 10)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
case 3:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 10, 14, 4, 12)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
case 4:
return ModelProvider.getModelProvider().getModel("repeater_off")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 12, 14, 4, 14)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 2, 2, 9, 7, 4)
.d("unlit_redstone_torch").uv(7, 13, 9, 15).noCull()
.u("unlit_redstone_torch").uv(7, 6, 9, 8).noCull()
.n("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.s("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.w("unlit_redstone_torch").uv(7, 6, 9, 11).noCull()
.e("unlit_redstone_torch").uv(7, 6, 9, 11).noCull();
}
}
private static Model getModelOnLocked(int delay) {
switch(delay) {
case 1:
default:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 6, 14, 4, 8)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
case 2:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 8, 14, 4, 10)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
case 3:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 10, 14, 4, 12)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
case 4:
return ModelProvider.getModelProvider().getModel("repeater_on")
.add(0, 0, 0, 16, 2, 16)
.d("concrete_plate").uv(0, 0, 16, 16)
.u().uv(0, 0, 16, 16).noCull()
.n("concrete_plate").uv(0, 14, 16, 16)
.s("concrete_plate").uv(0, 14, 16, 16)
.w("concrete_plate").uv(0, 14, 16, 16)
.e("concrete_plate").uv(0, 14, 16, 16)
.add(2, 2, 12, 14, 4, 14)
.d("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.u("bedrock").uv(7, 2, 9, 14).rot(90).noCull()
.n("bedrock").uv(2, 7, 14, 9).noCull()
.s("bedrock").uv(2, 7, 14, 9).noCull()
.w("bedrock").uv(6, 7, 8, 9).noCull()
.e("bedrock").uv(6, 7, 8, 9).noCull()
.add(7, 7, 2, 9, 7, 4)
.u("redstone_torch").uv(7, 6, 9, 8).noCull()
.add(7, 2, 1, 9, 8, 5)
.w("redstone_torch").uv(6, 5, 10, 11).noCull()
.e("redstone_torch").uv(6, 5, 10, 11).noCull()
.add(6, 2, 2, 10, 8, 4)
.n("redstone_torch").uv(6, 5, 10, 11).noCull()
.s("redstone_torch").uv(6, 5, 10, 11).noCull();
}
}
public Model getModel(ModelProvider provider, String name, State state) {
return (this.isRepeaterPowered ? (state.getValue(LOCKED) ? getModelOnLocked(state.getValue(DELAY)) :
getModelOn(state.getValue(DELAY))) : (state.getValue(LOCKED) ? getModelOffLocked(state.getValue(DELAY)) :
getModelOff(state.getValue(DELAY))))
.rotate(ModelRotation.getNorthRot(state.getValue(FACING).getOpposite()));
}
protected Item getItemToRegister() {
return this.isRepeaterPowered ? null : new ItemSmallBlock(this).setDisplay("Redstone-Verstärker").setTab(CheatTab.TECHNOLOGY);
}
public Property[] getUnsavedProperties() {
return new Property[] {LOCKED};
}
}

View file

@ -1,242 +0,0 @@
package common.block.tech;
import java.util.List;
import java.util.Map;
import common.block.Block;
import common.collect.Lists;
import common.collect.Maps;
import common.init.Blocks;
import common.init.Items;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.util.ParticleType;
import common.world.IWorldAccess;
import common.world.AWorldClient;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRedstoneTorch extends BlockTorch
{
private static Map<World, List<BlockRedstoneTorch.Toggle>> toggles = Maps.<World, List<BlockRedstoneTorch.Toggle>>newHashMap();
private final boolean isOn;
private boolean isBurnedOut(AWorldServer worldIn, BlockPos pos, boolean turnOff)
{
if (!toggles.containsKey(worldIn))
{
toggles.put(worldIn, Lists.<BlockRedstoneTorch.Toggle>newArrayList());
}
List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);
if (turnOff)
{
list.add(new BlockRedstoneTorch.Toggle(pos, worldIn.getTime()));
}
int i = 0;
for (int j = 0; j < list.size(); ++j)
{
BlockRedstoneTorch.Toggle blockredstonetorch$toggle = (BlockRedstoneTorch.Toggle)list.get(j);
if (blockredstonetorch$toggle.pos.equals(pos))
{
++i;
if (i >= 8)
{
return true;
}
}
}
return false;
}
public BlockRedstoneTorch(boolean isOn)
{
this.isOn = isOn;
// this.setTickRandomly(true);
this.setTab((CheatTab)null);
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn, BlockPos pos)
{
return 2;
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
if (this.isOn)
{
for (Facing enumfacing : Facing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
if (this.isOn)
{
for (Facing enumfacing : Facing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
}
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return this.isOn && state.getValue(FACING) != side ? 15 : 0;
}
private boolean shouldBeOff(World worldIn, BlockPos pos, State state)
{
Facing enumfacing = ((Facing)state.getValue(FACING)).getOpposite();
return worldIn.isSidePowered(pos.offset(enumfacing), enumfacing);
}
/**
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
*/
public void randomTick(AWorldServer worldIn, BlockPos pos, State state, Random random)
{
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
boolean flag = this.shouldBeOff(worldIn, pos, state);
List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);
while (list != null && !list.isEmpty() && worldIn.getTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
{
list.remove(0);
}
if (this.isOn)
{
if (flag)
{
worldIn.setState(pos, Blocks.unlit_redstone_torch.getState().withProperty(FACING, state.getValue(FACING)), 3);
if (this.isBurnedOut(worldIn, pos, true))
{
worldIn.playSound(SoundEvent.FIZZ, (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), 0.5F);
for (int i = 0; i < 5; ++i)
{
double d0 = (double)pos.getX() + rand.doublev() * 0.6D + 0.2D;
double d1 = (double)pos.getY() + rand.doublev() * 0.6D + 0.2D;
double d2 = (double)pos.getZ() + rand.doublev() * 0.6D + 0.2D;
worldIn.spawnParticle(ParticleType.SMOKE, d0, d1, d2);
}
worldIn.scheduleUpdate(pos, worldIn.getState(pos).getBlock(), 160);
}
}
}
else if (!flag && !this.isBurnedOut(worldIn, pos, false))
{
worldIn.setState(pos, Blocks.redstone_torch.getState().withProperty(FACING, state.getValue(FACING)), 3);
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!this.onNeighborChangeInternal(worldIn, pos, state))
{
if (this.isOn == this.shouldBeOff(worldIn, pos, state))
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn, pos));
}
}
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return side == Facing.DOWN ? this.getWeakPower(worldIn, pos, state, side) : 0;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.redstone_torch;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
{
if (this.isOn)
{
double d0 = (double)pos.getX() + 0.5D + (rand.doublev() - 0.5D) * 0.2D;
double d1 = (double)pos.getY() + 0.7D + (rand.doublev() - 0.5D) * 0.2D;
double d2 = (double)pos.getZ() + 0.5D + (rand.doublev() - 0.5D) * 0.2D;
Facing enumfacing = (Facing)state.getValue(FACING);
if (enumfacing.getAxis().isHorizontal())
{
Facing enumfacing1 = enumfacing.getOpposite();
double d3 = 0.27D;
d0 += 0.27D * (double)enumfacing1.getFrontOffsetX();
d1 += 0.22D;
d2 += 0.27D * (double)enumfacing1.getFrontOffsetZ();
}
worldIn.spawnParticle(ParticleType.DUST, d0, d1, d2, 0xff0000);
}
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.redstone_torch;
}
public boolean isAssociatedBlock(Block other)
{
return other == Blocks.unlit_redstone_torch || other == Blocks.redstone_torch;
}
public boolean isMagnetic() {
return true;
}
protected Item getItemToRegister() {
return this.isOn ? super.getItemToRegister() : null;
}
static class Toggle
{
BlockPos pos;
long time;
public Toggle(BlockPos pos, long time)
{
this.pos = pos;
this.time = time;
}
}
}

View file

@ -22,7 +22,6 @@ import common.util.Facing;
import common.world.Explosion;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockTNT extends Block
{

View file

@ -0,0 +1,66 @@
package common.block.tech;
import common.block.Block;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockToggleableLight extends Block {
private final boolean isOn;
public BlockToggleableLight(boolean isOn) {
super(Material.LOOSE);
this.isOn = isOn;
if(isOn)
this.setLightLevel(1.0F);
}
public void toggle(World worldIn, BlockPos pos) {
worldIn.setState(pos, this.isOn ? Blocks.lamp.getState() : Blocks.lit_lamp.getState(), 2);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC player, Facing side, float hitX, float hitY, float hitZ) {
if(!this.isOn) {
if(player.getCurrentEquippedItem() == null)
return super.onBlockActivated(worldIn, pos, state, player, side, hitX, hitY, hitZ);
Item item = player.getCurrentEquippedItem().getItem();
if(item != Items.flint_and_steel && item != Items.fireball)
return super.onBlockActivated(worldIn, pos, state, player, side, hitX, hitY, hitZ);
if(item == Items.flint_and_steel)
player.getCurrentEquippedItem().damage(1, player);
else
player.getCurrentEquippedItem().decrSize();
}
this.toggle(worldIn, pos);
worldIn.playAuxSFX(player, this.isOn ? 1004 : 1007, pos, 0);
return true;
}
public Item getItemDropped(State state, Random rand, int fortune) {
return Items.lamp;
}
public Item getItem(World worldIn, BlockPos pos) {
return Items.lamp;
}
public ItemStack createStackedBlock(State state) {
return new ItemStack(Items.lamp);
}
public boolean isMagnetic() {
return true;
}
protected Item getItemToRegister() {
return this.isOn ? null : super.getItemToRegister();
}
}

View file

@ -5,6 +5,7 @@ import common.block.DirectionalUp;
import common.block.Material;
import common.block.artificial.BlockFence;
import common.block.artificial.BlockStainedGlass;
import common.block.artificial.BlockWall;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.item.CheatTab;
@ -13,19 +14,16 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.rng.Random;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.HitPosition;
import common.util.ParticleType;
import common.util.Vec3;
import common.world.AWorldClient;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockTorch extends Block implements DirectionalUp
public abstract class BlockTorch extends Block implements DirectionalUp
{
private static boolean isBlockNormalCube(World world, BlockPos pos, boolean def) {
if(!World.isValid(pos) || (world.client && !world.isBlockLoaded(pos, false)))
@ -38,7 +36,6 @@ public class BlockTorch extends Block implements DirectionalUp
{
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.UP));
// this.setTickRandomly(true);
this.setTab(CheatTab.TECHNOLOGY);
this.setFlatItemTexture();
}
@ -70,7 +67,7 @@ public class BlockTorch extends Block implements DirectionalUp
else
{
Block block = worldIn.getState(pos).getBlock();
return block instanceof BlockFence || block == Blocks.glass || block == Blocks.cobblestone_wall || block instanceof BlockStainedGlass;
return block instanceof BlockFence || block == Blocks.glass || block instanceof BlockWall || block instanceof BlockStainedGlass;
}
}
@ -217,28 +214,6 @@ public class BlockTorch extends Block implements DirectionalUp
return super.collisionRayTrace(worldIn, pos, start, end);
}
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
{
Facing enumfacing = (Facing)state.getValue(FACING);
double d0 = (double)pos.getX() + 0.5D;
double d1 = (double)pos.getY() + 0.7D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.22D;
double d4 = 0.27D;
if (enumfacing.getAxis().isHorizontal())
{
Facing enumfacing1 = enumfacing.getOpposite();
worldIn.spawnParticle(ParticleType.SMOKE, d0 + d4 * (double)enumfacing1.getFrontOffsetX(), d1 + d3, d2 + d4 * (double)enumfacing1.getFrontOffsetZ());
worldIn.spawnParticle(ParticleType.FLAME, d0 + d4 * (double)enumfacing1.getFrontOffsetX(), d1 + d3, d2 + d4 * (double)enumfacing1.getFrontOffsetZ());
}
else
{
worldIn.spawnParticle(ParticleType.SMOKE, d0, d1, d2);
worldIn.spawnParticle(ParticleType.FLAME, d0, d1, d2);
}
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;

View file

@ -0,0 +1,51 @@
package common.block.tech;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockUnlitTorch extends BlockTorch {
private final int particleColor;
private BlockLitTorch lit;
public BlockUnlitTorch(int color) {
this.particleColor = color;
this.setTab(CheatTab.TECHNOLOGY);
}
void setLitTorch(BlockLitTorch lit) {
this.lit = lit;
}
public int getParticleColor() {
return this.particleColor;
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
if(playerIn.getCurrentEquippedItem() != null) {
Item item = playerIn.getCurrentEquippedItem().getItem();
if(item == Items.flint_and_steel || item == Items.fireball) {
worldIn.setState(pos, this.lit.getState().withProperty(FACING, state.getValue(FACING)).withProperty(BlockLitTorch.FUEL, 7), 3);
worldIn.playAuxSFX(playerIn, 1007, pos, 0);
if(item == Items.flint_and_steel) {
playerIn.getCurrentEquippedItem().damage(1, playerIn);
}
else {
playerIn.getCurrentEquippedItem().decrSize();
}
return true;
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
}
}

View file

@ -9,10 +9,8 @@ import common.block.Material;
import common.collect.Lists;
import common.collect.Sets;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.StackSize;
import common.item.block.ItemRedstone;
import common.item.block.ItemWire;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -34,345 +32,345 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockRedstoneWire extends Block
public class BlockWire extends Block
{
private static final Model redstone_none = ModelProvider.getModelProvider().getModel("redstone_dust_cross")
private static final Model wire_none = ModelProvider.getModelProvider().getModel("wire_cross")
.add(5, 0.25f, 5, 11, 0.25f, 11).noShade()
.u().uv(5, 5, 11, 11).tint().noCull()
.add(5, 0.25f, 5, 11, 0.25f, 11).noShade()
.u("redstone_dust_cross_overlay").uv(5, 5, 11, 11).noCull()
.u("wire_cross_overlay").uv(5, 5, 11, 11).noCull()
;
private static final Model redstone_nsew = ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static final Model wire_nsew = ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(0, 0, 16, 16).noCull()
;
private static final Model redstone_unusueuw = ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static final Model wire_unusueuw = ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(0, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0.25f, 0, 0, 0.25f, 16, 16).noShade()
.e("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.e("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0.25f, 0, 0, 0.25f, 16, 16).noShade()
.e("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.e("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
;
private static final Model redstone_unus = ModelProvider.getModelProvider().getModel("redstone_dust_cross")
private static final Model wire_unus = ModelProvider.getModelProvider().getModel("wire_cross")
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.u("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.u("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
;
private static final Model redstone_ueuw = ModelProvider.getModelProvider().getModel("redstone_dust_cross")
private static final Model wire_ueuw = ModelProvider.getModelProvider().getModel("wire_cross")
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line").uv(0, 0, 16, 16).tint().noCull()
.u("wire_line").uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_line_overlay").uv(0, 0, 16, 16).noCull()
.add(0.25f, 0, 0, 0.25f, 16, 16).noShade()
.e("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.e("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0.25f, 0, 0, 0.25f, 16, 16).noShade()
.e("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.e("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
;
private static Model redstone_n(boolean rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross")
private static Model wire_n(boolean rot) {
return ModelProvider.getModelProvider().getModel("wire_cross")
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.u("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.u("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
}
private static Model redstone_ne(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_ne(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u().uv(5, 0, 16, 11).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 11).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 11).noCull()
.rotate(rot);
}
private static Model redstone_uew(boolean rot) {
Model model = ModelProvider.getModelProvider().getModel("redstone_dust_cross")
private static Model wire_uew(boolean rot) {
Model model = ModelProvider.getModelProvider().getModel("wire_cross")
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line").uv(0, 0, 16, 16).tint().noCull()
.u("wire_line").uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_line_overlay").uv(0, 0, 16, 16).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull();
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull();
return rot ? model.uvLock().rotate(ModelRotation.X0_Y180) : model;
}
private static Model redstone_nue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_nue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u().uv(5, 0, 16, 11).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 11).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 11).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(270).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(270).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(270).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(270).noCull()
.rotate(rot);
}
private static Model redstone_une(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_une(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u().uv(5, 0, 16, 11).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 11).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 11).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_nse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_nse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.rotate(rot);
}
private static Model redstone_uns(boolean lock, ModelRotation rot) {
Model model = ModelProvider.getModelProvider().getModel("redstone_dust_cross")
private static Model wire_uns(boolean lock, ModelRotation rot) {
Model model = ModelProvider.getModelProvider().getModel("wire_cross")
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.u("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.u("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
return lock ? model.uvLock() : model;
}
private static Model redstone_nsue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_nsue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(270).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(270).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(270).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(270).noCull()
.rotate(rot);
}
private static Model redstone_unse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_nuse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_nuse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u().uv(5, 0, 16, 11).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 11).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 11).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 11).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unusue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unusue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unusew(boolean rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unusew(boolean rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(0, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot ? ModelRotation.X0_Y90 : ModelRotation.X0_Y0);
}
private static Model redstone_unusuew(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unusuew(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(0, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unuse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unuse(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_nusue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_nusue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.n("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 15.75f, 16, 16, 15.75f).noShade()
.n("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.n("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unsew(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unsew(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(0, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unsuew(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unsuew(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(0, 0, 16, 16).tint().noCull()
.add(0, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(0, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(0, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
private static Model redstone_unsue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("redstone_dust_cross").uvLock()
private static Model wire_unsue(ModelRotation rot) {
return ModelProvider.getModelProvider().getModel("wire_cross").uvLock()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u().uv(5, 0, 16, 16).tint().noCull()
.add(5, 0.25f, 0, 16, 0.25f, 16).noShade()
.u("redstone_dust_cross_overlay").uv(5, 0, 16, 16).noCull()
.u("wire_cross_overlay").uv(5, 0, 16, 16).noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.s("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(0, 0, 0.25f, 16, 16, 0.25f).noShade()
.s("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.s("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.w("wire_line").uv(0, 0, 16, 16).rot(90).tint().noCull()
.add(15.75f, 0, 0, 15.75f, 16, 16).noShade()
.w("redstone_dust_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.w("wire_line_overlay").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> NORTH = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("north", BlockRedstoneWire.EnumAttachPosition.class);
public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> EAST = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("east", BlockRedstoneWire.EnumAttachPosition.class);
public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> SOUTH = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("south", BlockRedstoneWire.EnumAttachPosition.class);
public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> WEST = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("west", BlockRedstoneWire.EnumAttachPosition.class);
public static final PropertyEnum<EnumAttachPosition> NORTH = PropertyEnum.<EnumAttachPosition>create("north", EnumAttachPosition.class);
public static final PropertyEnum<EnumAttachPosition> EAST = PropertyEnum.<EnumAttachPosition>create("east", EnumAttachPosition.class);
public static final PropertyEnum<EnumAttachPosition> SOUTH = PropertyEnum.<EnumAttachPosition>create("south", EnumAttachPosition.class);
public static final PropertyEnum<EnumAttachPosition> WEST = PropertyEnum.<EnumAttachPosition>create("west", EnumAttachPosition.class);
public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
private boolean canProvidePower = true;
private final Set<BlockPos> blocksNeedingUpdate = Sets.<BlockPos>newHashSet();
public BlockRedstoneWire()
public BlockWire()
{
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(NORTH, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(EAST, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(SOUTH, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(WEST, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(POWER, Integer.valueOf(0)));
this.setDefaultState(this.getBaseState().withProperty(NORTH, EnumAttachPosition.NONE).withProperty(EAST, EnumAttachPosition.NONE).withProperty(SOUTH, EnumAttachPosition.NONE).withProperty(WEST, EnumAttachPosition.NONE).withProperty(POWER, Integer.valueOf(0)));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
}
@ -389,19 +387,19 @@ public class BlockRedstoneWire extends Block
return state;
}
private BlockRedstoneWire.EnumAttachPosition getAttachPosition(IBlockAccess worldIn, BlockPos pos, Facing direction)
private EnumAttachPosition getAttachPosition(IBlockAccess worldIn, BlockPos pos, Facing direction)
{
BlockPos blockpos = pos.offset(direction);
Block block = worldIn.getState(pos.offset(direction)).getBlock();
if (!canConnectTo(worldIn.getState(blockpos), direction) && (block.isBlockNormalCube() || !canConnectUpwardsTo(worldIn.getState(blockpos.down()))))
if (!this.canConnectTo(worldIn.getState(blockpos), direction) && (block.isBlockNormalCube() || !this.canConnectUpwardsTo(worldIn.getState(blockpos.down()))))
{
Block block1 = worldIn.getState(pos.up()).getBlock();
return !block1.isBlockNormalCube() && block.isBlockNormalCube() && canConnectUpwardsTo(worldIn.getState(blockpos.up())) ? BlockRedstoneWire.EnumAttachPosition.UP : BlockRedstoneWire.EnumAttachPosition.NONE;
return !block1.isBlockNormalCube() && block.isBlockNormalCube() && this.canConnectUpwardsTo(worldIn.getState(blockpos.up())) ? EnumAttachPosition.UP : EnumAttachPosition.NONE;
}
else
{
return BlockRedstoneWire.EnumAttachPosition.SIDE;
return EnumAttachPosition.SIDE;
}
}
@ -434,7 +432,7 @@ public class BlockRedstoneWire extends Block
return worldIn.isBlockSolid(pos.down()) || worldIn.getState(pos.down()).getBlock() == Blocks.glowstone;
}
private State updateSurroundingRedstone(World worldIn, BlockPos pos, State state)
private State updateSurroundings(World worldIn, BlockPos pos, State state)
{
state = this.calculateCurrentChanges(worldIn, pos, pos, state);
List<BlockPos> list = Lists.newArrayList(this.blocksNeedingUpdate);
@ -455,7 +453,7 @@ public class BlockRedstoneWire extends Block
int j = 0;
j = this.getMaxCurrentStrength(worldIn, pos2, j);
this.canProvidePower = false;
int k = worldIn.isBlockIndirectlyGettingPowered(pos1);
int k = 0; // TODO: worldIn.isBlockIndirectlyGettingPowered(pos1);
this.canProvidePower = true;
if (k > 0 && k > j - 1)
@ -527,7 +525,7 @@ public class BlockRedstoneWire extends Block
}
/**
* Calls World.notifyNeighborsOfStateChange() for all neighboring blocks, but only if the given block is a redstone
* Calls World.notifyNeighborsOfStateChange() for all neighboring blocks, but only if the given block is a
* wire.
*/
private void notifyWireNeighborsOfStateChange(World worldIn, BlockPos pos)
@ -547,7 +545,7 @@ public class BlockRedstoneWire extends Block
{
if (!worldIn.client)
{
this.updateSurroundingRedstone(worldIn, pos, state);
this.updateSurroundings(worldIn, pos, state);
for (Facing enumfacing : Facing.Plane.VERTICAL)
{
@ -586,7 +584,7 @@ public class BlockRedstoneWire extends Block
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
this.updateSurroundingRedstone(worldIn, pos, state);
this.updateSurroundings(worldIn, pos, state);
for (Facing enumfacing1 : Facing.Plane.HORIZONTAL)
{
@ -631,7 +629,7 @@ public class BlockRedstoneWire extends Block
{
if (this.canPlaceBlockAt(worldIn, pos))
{
this.updateSurroundingRedstone(worldIn, pos, state);
this.updateSurroundings(worldIn, pos, state);
}
else
{
@ -646,7 +644,7 @@ public class BlockRedstoneWire extends Block
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.redstone;
return this.getItem();
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
@ -707,32 +705,32 @@ public class BlockRedstoneWire extends Block
Block block = iblockstate.getBlock();
boolean flag = block.isNormalCube();
boolean flag1 = worldIn.getState(pos.up()).getBlock().isNormalCube();
return !flag1 && flag && canConnectUpwardsTo(worldIn, blockpos.up()) ? true : (canConnectTo(iblockstate, side) ? true : (block == Blocks.powered_repeater && iblockstate.getValue(BlockRedstoneDiode.FACING) == side ? true : !flag && canConnectUpwardsTo(worldIn, blockpos.down())));
return !flag1 && flag && this.canConnectUpwardsTo(worldIn, blockpos.up()) ? true : (this.canConnectTo(iblockstate, side) ? true : /* (block == Blocks.powered_repeater && iblockstate.getValue(BlockwireDiode.FACING) == side ? true : */ !flag && this.canConnectUpwardsTo(worldIn, blockpos.down()));
}
protected static boolean canConnectUpwardsTo(IBlockAccess worldIn, BlockPos pos)
protected boolean canConnectUpwardsTo(IBlockAccess worldIn, BlockPos pos)
{
return canConnectUpwardsTo(worldIn.getState(pos));
return this.canConnectUpwardsTo(worldIn.getState(pos));
}
protected static boolean canConnectUpwardsTo(State state)
protected boolean canConnectUpwardsTo(State state)
{
return canConnectTo(state, (Facing)null);
return this.canConnectTo(state, (Facing)null);
}
protected static boolean canConnectTo(State blockState, Facing side)
protected boolean canConnectTo(State blockState, Facing side)
{
Block block = blockState.getBlock();
if (block == Blocks.redstone)
if (block == this)
{
return true;
}
else if (Blocks.repeater.isAssociated(block))
{
Facing enumfacing = (Facing)blockState.getValue(BlockRedstoneRepeater.FACING);
return enumfacing == side || enumfacing.getOpposite() == side;
}
// else if (Blocks.repeater.isAssociated(block))
// {
// Facing enumfacing = (Facing)blockState.getValue(BlockwireRepeater.FACING);
// return enumfacing == side || enumfacing.getOpposite() == side;
// }
else
{
return block.canProvidePower() && side != null;
@ -791,7 +789,7 @@ public class BlockRedstoneWire extends Block
public Item getItem(World worldIn, BlockPos pos)
{
return Items.redstone;
return this.getItem();
}
public BlockLayer getBlockLayer()
@ -823,186 +821,186 @@ public class BlockRedstoneWire extends Block
boolean er = state.getValue(EAST) == EnumAttachPosition.SIDE;
if(ea && na && sa && wa)
return redstone_none;
return wire_none;
else if(eu && nu && su && wu)
return redstone_unusueuw;
return wire_unusueuw;
else if(er && nr && sr && wr)
return redstone_nsew;
return wire_nsew;
else if(ea && nu && su && wa)
return redstone_unus;
return wire_unus;
else if(eu && na && sa && wu)
return redstone_ueuw;
return wire_ueuw;
else if(ea && nr && sa && wa)
return redstone_n(false);
return wire_n(false);
else if(ea && na && sr && wa)
return redstone_n(false);
return wire_n(false);
else if(er && na && sa && wa)
return redstone_n(true);
return wire_n(true);
else if(ea && na && sa && wr)
return redstone_n(true);
return wire_n(true);
else if(ea && nu && sa && wa)
return redstone_uns(false, ModelRotation.X0_Y0);
return wire_uns(false, ModelRotation.X0_Y0);
else if(ea && na && su && wa)
return redstone_uns(true, ModelRotation.X0_Y180);
return wire_uns(true, ModelRotation.X0_Y180);
else if(eu && na && sa && wa)
return redstone_uew(false);
return wire_uew(false);
else if(ea && na && sa && wu)
return redstone_uew(true);
return wire_uew(true);
else if(er && nr && sa && wa)
return redstone_ne(ModelRotation.X0_Y0);
return wire_ne(ModelRotation.X0_Y0);
else if(er && nu && sa && wa)
return redstone_une(ModelRotation.X0_Y0);
return wire_une(ModelRotation.X0_Y0);
else if(eu && nr && sa && wa)
return redstone_nue(ModelRotation.X0_Y0);
return wire_nue(ModelRotation.X0_Y0);
else if(eu && nu && sa && wa)
return redstone_unue(ModelRotation.X0_Y0);
return wire_unue(ModelRotation.X0_Y0);
else if(er && na && sr && wa)
return redstone_ne(ModelRotation.X0_Y90);
return wire_ne(ModelRotation.X0_Y90);
else if(eu && na && sr && wa)
return redstone_une(ModelRotation.X0_Y90);
return wire_une(ModelRotation.X0_Y90);
else if(er && na && su && wa)
return redstone_nue(ModelRotation.X0_Y90);
return wire_nue(ModelRotation.X0_Y90);
else if(eu && na && su && wa)
return redstone_unue(ModelRotation.X0_Y90);
return wire_unue(ModelRotation.X0_Y90);
else if(ea && na && sr && wr)
return redstone_ne(ModelRotation.X0_Y180);
return wire_ne(ModelRotation.X0_Y180);
else if(ea && na && su && wr)
return redstone_une(ModelRotation.X0_Y180);
return wire_une(ModelRotation.X0_Y180);
else if(ea && na && sr && wu)
return redstone_nue(ModelRotation.X0_Y180);
return wire_nue(ModelRotation.X0_Y180);
else if(ea && na && su && wu)
return redstone_unue(ModelRotation.X0_Y180);
return wire_unue(ModelRotation.X0_Y180);
else if(ea && nr && sa && wr)
return redstone_ne(ModelRotation.X0_Y270);
return wire_ne(ModelRotation.X0_Y270);
else if(ea && nr && sa && wu)
return redstone_une(ModelRotation.X0_Y270);
return wire_une(ModelRotation.X0_Y270);
else if(ea && nu && sa && wr)
return redstone_nue(ModelRotation.X0_Y270);
return wire_nue(ModelRotation.X0_Y270);
else if(ea && nu && sa && wu)
return redstone_unue(ModelRotation.X0_Y270);
return wire_unue(ModelRotation.X0_Y270);
else if(ea && nr && sr && wa)
return redstone_n(false);
return wire_n(false);
else if(ea && nu && sr && wa)
return redstone_uns(false, ModelRotation.X0_Y0);
return wire_uns(false, ModelRotation.X0_Y0);
else if(ea && nr && su && wa)
return redstone_uns(false, ModelRotation.X0_Y180);
return wire_uns(false, ModelRotation.X0_Y180);
else if(er && na && sa && wr)
return redstone_n(true);
return wire_n(true);
else if(eu && na && sa && wr)
return redstone_uns(false, ModelRotation.X0_Y90);
return wire_uns(false, ModelRotation.X0_Y90);
else if(er && na && sa && wu)
return redstone_uns(false, ModelRotation.X0_Y270);
return wire_uns(false, ModelRotation.X0_Y270);
else if(er && nr && sr && wa)
return redstone_nse(ModelRotation.X0_Y0);
return wire_nse(ModelRotation.X0_Y0);
else if(er && nu && sr && wa)
return redstone_unse(ModelRotation.X0_Y0);
return wire_unse(ModelRotation.X0_Y0);
else if(er && nr && su && wa)
return redstone_nuse(ModelRotation.X0_Y0);
return wire_nuse(ModelRotation.X0_Y0);
else if(eu && nr && sr && wa)
return redstone_nsue(ModelRotation.X0_Y0);
return wire_nsue(ModelRotation.X0_Y0);
else if(eu && nr && su && wa)
return redstone_nusue(ModelRotation.X0_Y0);
return wire_nusue(ModelRotation.X0_Y0);
else if(er && nu && su && wa)
return redstone_unuse(ModelRotation.X0_Y0);
return wire_unuse(ModelRotation.X0_Y0);
else if(eu && nu && sr && wa)
return redstone_unsue(ModelRotation.X0_Y0);
return wire_unsue(ModelRotation.X0_Y0);
else if(eu && nu && su && wa)
return redstone_unusue(ModelRotation.X0_Y0);
return wire_unusue(ModelRotation.X0_Y0);
else if(er && na && sr && wr)
return redstone_nse(ModelRotation.X0_Y90);
return wire_nse(ModelRotation.X0_Y90);
else if(eu && na && sr && wr)
return redstone_unse(ModelRotation.X0_Y90);
return wire_unse(ModelRotation.X0_Y90);
else if(er && na && sr && wu)
return redstone_nuse(ModelRotation.X0_Y90);
return wire_nuse(ModelRotation.X0_Y90);
else if(er && na && su && wr)
return redstone_nsue(ModelRotation.X0_Y90);
return wire_nsue(ModelRotation.X0_Y90);
else if(er && na && su && wu)
return redstone_nusue(ModelRotation.X0_Y90);
return wire_nusue(ModelRotation.X0_Y90);
else if(eu && na && sr && wu)
return redstone_unuse(ModelRotation.X0_Y90);
return wire_unuse(ModelRotation.X0_Y90);
else if(eu && na && su && wr)
return redstone_unsue(ModelRotation.X0_Y90);
return wire_unsue(ModelRotation.X0_Y90);
else if(eu && na && su && wu)
return redstone_unusue(ModelRotation.X0_Y90);
return wire_unusue(ModelRotation.X0_Y90);
else if(ea && nr && sr && wr)
return redstone_nse(ModelRotation.X0_Y180);
return wire_nse(ModelRotation.X0_Y180);
else if(ea && nr && su && wr)
return redstone_unse(ModelRotation.X0_Y180);
return wire_unse(ModelRotation.X0_Y180);
else if(ea && nu && sr && wr)
return redstone_nuse(ModelRotation.X0_Y180);
return wire_nuse(ModelRotation.X0_Y180);
else if(ea && nr && sr && wu)
return redstone_nsue(ModelRotation.X0_Y180);
return wire_nsue(ModelRotation.X0_Y180);
else if(ea && nu && sr && wu)
return redstone_nusue(ModelRotation.X0_Y180);
return wire_nusue(ModelRotation.X0_Y180);
else if(ea && nu && su && wr)
return redstone_unuse(ModelRotation.X0_Y180);
return wire_unuse(ModelRotation.X0_Y180);
else if(ea && nr && su && wu)
return redstone_unsue(ModelRotation.X0_Y180);
return wire_unsue(ModelRotation.X0_Y180);
else if(ea && nu && su && wu)
return redstone_unusue(ModelRotation.X0_Y180);
return wire_unusue(ModelRotation.X0_Y180);
else if(er && nr && sa && wr)
return redstone_nse(ModelRotation.X0_Y270);
return wire_nse(ModelRotation.X0_Y270);
else if(er && nr && sa && wu)
return redstone_unse(ModelRotation.X0_Y270);
return wire_unse(ModelRotation.X0_Y270);
else if(eu && nr && sa && wr)
return redstone_nuse(ModelRotation.X0_Y270);
return wire_nuse(ModelRotation.X0_Y270);
else if(er && nu && sa && wr)
return redstone_nsue(ModelRotation.X0_Y270);
return wire_nsue(ModelRotation.X0_Y270);
else if(eu && nu && sa && wr)
return redstone_nusue(ModelRotation.X0_Y270);
return wire_nusue(ModelRotation.X0_Y270);
else if(eu && nr && sa && wu)
return redstone_unuse(ModelRotation.X0_Y270);
return wire_unuse(ModelRotation.X0_Y270);
else if(er && nu && sa && wu)
return redstone_unsue(ModelRotation.X0_Y270);
return wire_unsue(ModelRotation.X0_Y270);
else if(eu && nu && sa && wu)
return redstone_unusue(ModelRotation.X0_Y270);
return wire_unusue(ModelRotation.X0_Y270);
else if(er && nu && sr && wr)
return redstone_unsew(ModelRotation.X0_Y0);
return wire_unsew(ModelRotation.X0_Y0);
else if(er && nr && su && wr)
return redstone_unsew(ModelRotation.X0_Y180);
return wire_unsew(ModelRotation.X0_Y180);
else if(eu && nr && sr && wr)
return redstone_unsew(ModelRotation.X0_Y90);
return wire_unsew(ModelRotation.X0_Y90);
else if(er && nr && sr && wu)
return redstone_unsew(ModelRotation.X0_Y270);
return wire_unsew(ModelRotation.X0_Y270);
else if(er && nu && su && wr)
return redstone_unusew(false);
return wire_unusew(false);
else if(eu && nr && sr && wu)
return redstone_unusew(true);
return wire_unusew(true);
else if(eu && nu && sr && wr)
return redstone_unsuew(ModelRotation.X0_Y0);
return wire_unsuew(ModelRotation.X0_Y0);
else if(eu && nr && su && wr)
return redstone_unsuew(ModelRotation.X0_Y90);
return wire_unsuew(ModelRotation.X0_Y90);
else if(er && nr && su && wu)
return redstone_unsuew(ModelRotation.X0_Y180);
return wire_unsuew(ModelRotation.X0_Y180);
else if(er && nu && sr && wu)
return redstone_unsuew(ModelRotation.X0_Y270);
return wire_unsuew(ModelRotation.X0_Y270);
else if(eu && nu && su && wr)
return redstone_unusuew(ModelRotation.X0_Y0);
return wire_unusuew(ModelRotation.X0_Y0);
else if(eu && nr && su && wu)
return redstone_unusuew(ModelRotation.X0_Y90);
return wire_unusuew(ModelRotation.X0_Y90);
else if(er && nu && su && wu)
return redstone_unusuew(ModelRotation.X0_Y180);
return wire_unusuew(ModelRotation.X0_Y180);
else if(eu && nu && sr && wu)
return redstone_unusuew(ModelRotation.X0_Y270);
return wire_unusuew(ModelRotation.X0_Y270);
else
return redstone_none;
return wire_none;
}
public Property<?>[] getIgnoredProperties() {
@ -1010,7 +1008,7 @@ public class BlockRedstoneWire extends Block
}
protected Item getItemToRegister() {
return new ItemRedstone(Blocks.redstone).setDisplay("Redstone").setMaxAmount(StackSize.XL);
return new ItemWire(this);
}
public Property[] getUnsavedProperties() {

View file

@ -1,7 +1,6 @@
package common.entity.item;
import common.block.tech.BlockRailBase;
import common.block.tech.BlockRailPowered;
import common.block.tech.BlockRail;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.types.EntityLiving;
@ -247,7 +246,7 @@ public abstract class EntityCart extends Entity
int l = ExtMath.floord(this.posY);
int i1 = ExtMath.floord(this.posZ);
if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(k, l - 1, i1)))
if (BlockRail.isRailBlock(this.worldObj, new BlockPos(k, l - 1, i1)))
{
--l;
}
@ -255,14 +254,14 @@ public abstract class EntityCart extends Entity
BlockPos blockpos = new BlockPos(k, l, i1);
State iblockstate = this.worldObj.getState(blockpos);
if (BlockRailBase.isRailBlock(iblockstate))
if (BlockRail.isRailBlock(iblockstate))
{
this.func_180460_a(blockpos, iblockstate);
this.moveRailedCart(blockpos, iblockstate);
if (iblockstate.getBlock() == Blocks.activator_rail)
{
this.onActivatorRailPass(k, l, i1, ((Boolean)iblockstate.getValue(BlockRailPowered.POWERED)).booleanValue());
}
// if (iblockstate.getBlock() == Blocks.activator_rail) // TODO: activation
// {
// this.onActivatorRailPass(k, l, i1, ((Boolean)iblockstate.getValue(BlockRailPowered.POWERED)).booleanValue());
// }
}
else
{
@ -358,23 +357,23 @@ public abstract class EntityCart extends Entity
}
protected void func_180460_a(BlockPos p_180460_1_, State p_180460_2_)
protected void moveRailedCart(BlockPos pos, State state)
{
this.fallDistance = 0.0F;
Vec3 vec3 = this.func_70489_a(this.posX, this.posY, this.posZ);
this.posY = (double)p_180460_1_.getY();
boolean flag = false;
boolean flag1 = false;
BlockRailBase blockrailbase = (BlockRailBase)p_180460_2_.getBlock();
this.posY = (double)pos.getY();
boolean accel = false;
boolean brake = false;
BlockRail blockrailbase = (BlockRail)state.getBlock();
if (blockrailbase == Blocks.golden_rail)
if (true) // TODO: power!
{
flag = ((Boolean)p_180460_2_.getValue(BlockRailPowered.POWERED)).booleanValue();
flag1 = !flag;
accel = true; // ((Boolean)state.getValue(BlockRailPowered.POWERED)).booleanValue();
brake = !accel;
}
double d0 = 0.0078125D;
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_180460_2_.getValue(blockrailbase.getShapeProperty());
BlockRail.EnumRailDirection blockrailbase$enumraildirection = (BlockRail.EnumRailDirection)state.getValue(BlockRail.SHAPE);
switch (blockrailbase$enumraildirection)
{
@ -434,12 +433,12 @@ public abstract class EntityCart extends Entity
{
this.motionX += d7 * 0.1D;
this.motionZ += d8 * 0.1D;
flag1 = false;
brake = false;
}
}
}
if (flag1)
if (brake)
{
double d17 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
@ -458,22 +457,22 @@ public abstract class EntityCart extends Entity
}
double d18 = 0.0D;
double d19 = (double)p_180460_1_.getX() + 0.5D + (double)aint[0][0] * 0.5D;
double d20 = (double)p_180460_1_.getZ() + 0.5D + (double)aint[0][2] * 0.5D;
double d21 = (double)p_180460_1_.getX() + 0.5D + (double)aint[1][0] * 0.5D;
double d10 = (double)p_180460_1_.getZ() + 0.5D + (double)aint[1][2] * 0.5D;
double d19 = (double)pos.getX() + 0.5D + (double)aint[0][0] * 0.5D;
double d20 = (double)pos.getZ() + 0.5D + (double)aint[0][2] * 0.5D;
double d21 = (double)pos.getX() + 0.5D + (double)aint[1][0] * 0.5D;
double d10 = (double)pos.getZ() + 0.5D + (double)aint[1][2] * 0.5D;
d1 = d21 - d19;
d2 = d10 - d20;
if (d1 == 0.0D)
{
this.posX = (double)p_180460_1_.getX() + 0.5D;
d18 = this.posZ - (double)p_180460_1_.getZ();
this.posX = (double)pos.getX() + 0.5D;
d18 = this.posZ - (double)pos.getZ();
}
else if (d2 == 0.0D)
{
this.posZ = (double)p_180460_1_.getZ() + 0.5D;
d18 = this.posX - (double)p_180460_1_.getX();
this.posZ = (double)pos.getZ() + 0.5D;
d18 = this.posX - (double)pos.getX();
}
else
{
@ -499,11 +498,11 @@ public abstract class EntityCart extends Entity
d23 = ExtMath.clampd(d23, -d13, d13);
this.moveEntity(d22, 0.0D, d23);
if (aint[0][1] != 0 && ExtMath.floord(this.posX) - p_180460_1_.getX() == aint[0][0] && ExtMath.floord(this.posZ) - p_180460_1_.getZ() == aint[0][2])
if (aint[0][1] != 0 && ExtMath.floord(this.posX) - pos.getX() == aint[0][0] && ExtMath.floord(this.posZ) - pos.getZ() == aint[0][2])
{
this.setPosition(this.posX, this.posY + (double)aint[0][1], this.posZ);
}
else if (aint[1][1] != 0 && ExtMath.floord(this.posX) - p_180460_1_.getX() == aint[1][0] && ExtMath.floord(this.posZ) - p_180460_1_.getZ() == aint[1][2])
else if (aint[1][1] != 0 && ExtMath.floord(this.posX) - pos.getX() == aint[1][0] && ExtMath.floord(this.posZ) - pos.getZ() == aint[1][2])
{
this.setPosition(this.posX, this.posY + (double)aint[1][1], this.posZ);
}
@ -528,14 +527,14 @@ public abstract class EntityCart extends Entity
int j = ExtMath.floord(this.posX);
int i = ExtMath.floord(this.posZ);
if (j != p_180460_1_.getX() || i != p_180460_1_.getZ())
if (j != pos.getX() || i != pos.getZ())
{
d5 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.motionX = d5 * (double)(j - p_180460_1_.getX());
this.motionZ = d5 * (double)(i - p_180460_1_.getZ());
this.motionX = d5 * (double)(j - pos.getX());
this.motionZ = d5 * (double)(i - pos.getZ());
}
if (flag)
if (accel)
{
double d15 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
@ -545,24 +544,24 @@ public abstract class EntityCart extends Entity
this.motionX += this.motionX / d15 * d16;
this.motionZ += this.motionZ / d15 * d16;
}
else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
else if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.EAST_WEST)
{
if (this.worldObj.getState(p_180460_1_.west()).getBlock().isNormalCube())
if (this.worldObj.getState(pos.west()).getBlock().isNormalCube())
{
this.motionX = 0.02D;
}
else if (this.worldObj.getState(p_180460_1_.east()).getBlock().isNormalCube())
else if (this.worldObj.getState(pos.east()).getBlock().isNormalCube())
{
this.motionX = -0.02D;
}
}
else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
else if (blockrailbase$enumraildirection == BlockRail.EnumRailDirection.NORTH_SOUTH)
{
if (this.worldObj.getState(p_180460_1_.north()).getBlock().isNormalCube())
if (this.worldObj.getState(pos.north()).getBlock().isNormalCube())
{
this.motionZ = 0.02D;
}
else if (this.worldObj.getState(p_180460_1_.south()).getBlock().isNormalCube())
else if (this.worldObj.getState(pos.south()).getBlock().isNormalCube())
{
this.motionZ = -0.02D;
}
@ -605,16 +604,16 @@ public abstract class EntityCart extends Entity
int j = ExtMath.floord(p_70495_3_);
int k = ExtMath.floord(p_70495_5_);
if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k)))
if (BlockRail.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k)))
{
--j;
}
State iblockstate = this.worldObj.getState(new BlockPos(i, j, k));
if (BlockRailBase.isRailBlock(iblockstate))
if (BlockRail.isRailBlock(iblockstate))
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty());
BlockRail.EnumRailDirection blockrailbase$enumraildirection = (BlockRail.EnumRailDirection)iblockstate.getValue(BlockRail.SHAPE);
p_70495_3_ = (double)j;
if (blockrailbase$enumraildirection.isAscending())
@ -654,16 +653,16 @@ public abstract class EntityCart extends Entity
int j = ExtMath.floord(p_70489_3_);
int k = ExtMath.floord(p_70489_5_);
if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k)))
if (BlockRail.isRailBlock(this.worldObj, new BlockPos(i, j - 1, k)))
{
--j;
}
State iblockstate = this.worldObj.getState(new BlockPos(i, j, k));
if (BlockRailBase.isRailBlock(iblockstate))
if (BlockRail.isRailBlock(iblockstate))
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty());
BlockRail.EnumRailDirection blockrailbase$enumraildirection = (BlockRail.EnumRailDirection)iblockstate.getValue(BlockRail.SHAPE);
int[][] aint = matrix[blockrailbase$enumraildirection.ordinal()];
double d0 = 0.0D;
double d1 = (double)i + 0.5D + (double)aint[0][0] * 0.5D;

View file

@ -133,48 +133,6 @@ public class EntityLeashKnot extends Entity
}
}
// /**
// * checks to make sure painting can be placed there
// */
// public boolean onValidSurface()
// {
// if (!this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty())
// {
// return false;
// }
// else
// {
// int i = Math.max(1, this.getWidthPixels() / 16);
// int j = Math.max(1, this.getHeightPixels() / 16);
// BlockPos blockpos = this.hangingPosition.offset(this.facingDirection.getOpposite());
// Facing enumfacing = this.facingDirection.rotateYCCW();
//
// for (int k = 0; k < i; ++k)
// {
// for (int l = 0; l < j; ++l)
// {
// BlockPos blockpos1 = blockpos.offset(enumfacing, k).up(l);
// Block block = this.worldObj.getState(blockpos1).getBlock();
//
// if (!block.getMaterial().isSolid() && !BlockRedstoneDiode.isRedstoneRepeaterBlockID(block))
// {
// return false;
// }
// }
// }
//
// for (Entity entity : this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()))
// {
// if (entity instanceof EntityLeashKnot)
// {
// return false;
// }
// }
//
// return true;
// }
// }
/**
* Returns true if other Entities should be prevented from moving through this Entity.
*/

View file

@ -1,6 +1,6 @@
package common.entity.item;
import common.block.tech.BlockRailBase;
import common.block.tech.BlockRail;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
@ -198,12 +198,12 @@ public class EntityTntCart extends EntityCart
*/
public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, State blockStateIn)
{
return !this.isIgnited() || !BlockRailBase.isRailBlock(blockStateIn) && !BlockRailBase.isRailBlock(worldIn, pos.up()) ? super.getExplosionResistance(explosionIn, worldIn, pos, blockStateIn) : 0.0F;
return !this.isIgnited() || !BlockRail.isRailBlock(blockStateIn) && !BlockRail.isRailBlock(worldIn, pos.up()) ? super.getExplosionResistance(explosionIn, worldIn, pos, blockStateIn) : 0.0F;
}
public boolean verifyExplosion(Explosion explosionIn, World worldIn, BlockPos pos, State blockStateIn, float p_174816_5_)
{
return !this.isIgnited() || !BlockRailBase.isRailBlock(blockStateIn) && !BlockRailBase.isRailBlock(worldIn, pos.up()) ? super.verifyExplosion(explosionIn, worldIn, pos, blockStateIn, p_174816_5_) : false;
return !this.isIgnited() || !BlockRail.isRailBlock(blockStateIn) && !BlockRail.isRailBlock(worldIn, pos.up()) ? super.verifyExplosion(explosionIn, worldIn, pos, blockStateIn, p_174816_5_) : false;
}
protected void readEntity(TagObject tagCompund)

View file

@ -66,6 +66,7 @@ import common.item.tool.ItemArmor;
import common.item.tool.ItemBow;
import common.item.tool.ItemGunBase;
import common.item.tool.ItemHoe;
import common.item.tool.ItemKey;
import common.item.tool.ItemPotion;
import common.item.tool.ItemShears;
import common.item.tool.ItemSword;
@ -4138,7 +4139,7 @@ public abstract class EntityNPC extends EntityLiving
public boolean canOpen(String code)
{
ItemStack stack = this.getCurrentEquippedItem();
return stack != null && stack.getItem() == Items.key &&
return stack != null && stack.getItem() instanceof ItemKey &&
stack.hasDisplayName() && stack.getDisplayName().equals(code);
}

View file

@ -11,7 +11,7 @@ import common.block.artificial.BlockBed;
import common.block.artificial.BlockBookshelf;
import common.block.artificial.BlockCake;
import common.block.artificial.BlockCarpet;
import common.block.artificial.BlockCompressedPowered;
import common.block.artificial.BlockMagnetic;
import common.block.artificial.BlockDoor;
import common.block.artificial.BlockDragonEgg;
import common.block.artificial.BlockFence;
@ -82,7 +82,6 @@ import common.block.natural.BlockObsidian;
import common.block.natural.BlockOre;
import common.block.natural.BlockPackedIce;
import common.block.natural.BlockPodzol;
import common.block.natural.BlockRedstoneOre;
import common.block.natural.BlockSandStone;
import common.block.natural.BlockSlime;
import common.block.natural.BlockSnow;
@ -116,18 +115,14 @@ import common.block.tech.BlockPistonMoving;
import common.block.tech.BlockPressurePlate;
import common.block.tech.BlockPressurePlateWeighted;
import common.block.tech.BlockRail;
import common.block.tech.BlockRailDetector;
import common.block.tech.BlockRailPowered;
import common.block.tech.BlockRedstoneComparator;
import common.block.tech.BlockRedstoneLight;
import common.block.tech.BlockRedstoneRepeater;
import common.block.tech.BlockRedstoneTorch;
import common.block.tech.BlockRedstoneWire;
import common.block.tech.BlockToggleableLight;
import common.block.tech.BlockLitTorch;
import common.block.tech.BlockWire;
import common.block.tech.BlockTNT;
import common.block.tech.BlockTianReactor;
import common.block.tech.BlockTorch;
import common.block.tech.BlockTripWire;
import common.block.tech.BlockTripWireHook;
import common.block.tech.BlockUnlitTorch;
import common.block.tech.BlockWarpChest;
import common.block.tech.BlockWorkbench;
import common.block.tile.BlockStandingSign;
@ -317,11 +312,9 @@ public abstract class BlockRegistry {
.setDisplay("Quarzerz"));
register("black_quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
.setDisplay("Schwarzes Quarzerz"));
register("redstone_ore", (new BlockRedstoneOre(false)).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
.setDisplay("Redstone-Erz").setTab(CheatTab.GEMS).setMiningLevel(2));
register("lit_redstone_ore", (new BlockRedstoneOre(true)).setLightLevel(0.625F).setHardness(3.0F).setResistance(5.0F)
.setStepSound(SoundType.STONE).setDisplay("Redstone-Erz").setMiningLevel(2));
register("charge_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE)
.setDisplay("Geladenes Erz").setMiningLevel(2));
for(MetalType metal : MetalType.values()) {
// String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1);
register(metal.name + "_ore", (new BlockMetalOre(metal)).setHardness(3.0F).setResistance(5.0F)
@ -414,8 +407,8 @@ public abstract class BlockRegistry {
.setStepSound(SoundType.STONE).setDisplay("Lapislazuliblock").setTab(CheatTab.GEMS).setMiningLevel(1));
register("emerald_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
.setStepSound(SoundType.STONE).setDisplay("Smaragdblock").setTab(CheatTab.GEMS).setMiningLevel(2));
register("redstone_block", (new BlockCompressedPowered(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
.setStepSound(SoundType.STONE).setDisplay("Redstone-Block").setTab(CheatTab.TECHNOLOGY));
register("charged_block", (new BlockMagnetic(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
.setStepSound(SoundType.STONE).setDisplay("Geladener Block").setTab(CheatTab.GEMS));
register("glass", (new BlockGlass()).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glas"));
for(DyeColor color : DyeColor.values()) {
@ -439,9 +432,6 @@ public abstract class BlockRegistry {
}
register("ladder", (new BlockLadder()).setHardness(0.4F).setStepSound(SoundType.LADDER).setDisplay("Leiter").setAxeHarvestable());
register("torch", (new BlockTorch()).setHardness(0.0F).setLightLevel(0.9375F).setStepSound(SoundType.WOOD).setDisplay("Fackel"));
register("lamp", (new Block(Material.TRANSLUCENT)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F)
.setDisplay("Lampe").setTab(CheatTab.TECHNOLOGY));
register("bookshelf", (new BlockBookshelf()).setHardness(1.5F).setStepSound(SoundType.WOOD).setDisplay("Bücherregal"));
register("cake", (new BlockCake()).setHardness(0.5F).setStepSound(SoundType.CLOTH).setDisplay("Kuchen"));
register("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setStepSound(SoundType.STONE)
@ -645,9 +635,6 @@ public abstract class BlockRegistry {
register("tian_reactor", (new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Tianreaktor"));
register("rail", (new BlockRail()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Schiene").setMiningLevel(0));
register("golden_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Antriebsschiene").setMiningLevel(0));
register("detector_rail", (new BlockRailDetector()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Sensorschiene").setMiningLevel(0));
register("activator_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Aktivierungsschiene").setMiningLevel(0));
register("lever", (new BlockLever()).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Hebel"));
@ -664,18 +651,21 @@ public abstract class BlockRegistry {
register("wooden_button", (new BlockButton(true, 30, "oak_planks")).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Knopf"));
register("red_button", (new BlockButton(true, 10, "red_button")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf"));
register("redstone", (new BlockRedstoneWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Redstone-Staub"));
register("unlit_redstone_torch", (new BlockRedstoneTorch(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Fackel"));
register("redstone_torch", (new BlockRedstoneTorch(true)).setHardness(0.0F).setLightLevel(0.5F).setStepSound(SoundType.WOOD)
.setDisplay("Redstone-Fackel").setTab(CheatTab.TECHNOLOGY));
register("repeater", (new BlockRedstoneRepeater(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker"));
register("powered_repeater", (new BlockRedstoneRepeater(true)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker"));
register("comparator", (new BlockRedstoneComparator(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator"));
register("powered_comparator", (new BlockRedstoneComparator(true)).setHardness(0.0F).setLightLevel(0.625F)
.setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator"));
register("redstone_lamp", (new BlockRedstoneLight(false)).setHardness(0.3F).setStepSound(SoundType.GLASS)
.setDisplay("Redstone-Lampe").setTab(CheatTab.TECHNOLOGY));
register("lit_redstone_lamp", (new BlockRedstoneLight(true)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Redstone-Lampe"));
register("wire", (new BlockWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Kabel"));
BlockUnlitTorch torch;
register("torch", (torch = new BlockUnlitTorch(0xffffffff)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Fackel"));
register("lit_torch", (new BlockLitTorch(torch)).setHardness(0.0F).setLightLevel(0.9375F).setStepSound(SoundType.WOOD).setDisplay("Fackel"));
BlockUnlitTorch tianTorch;
register("tian_torch", (tianTorch = new BlockUnlitTorch(0x7f00ff)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Tian-Fackel"));
register("lit_tian_torch", (new BlockLitTorch(tianTorch)).setHardness(0.0F).setLightLevel(0.5F).setStepSound(SoundType.WOOD)
.setDisplay("Tian-Fackel"));
BlockUnlitTorch soulTorch;
register("soul_torch", (soulTorch = new BlockUnlitTorch(0x1f1fff)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Seelenfackel"));
register("lit_soul_torch", (new BlockLitTorch(soulTorch)).setHardness(0.0F).setLightLevel(0.75F).setStepSound(SoundType.WOOD)
.setDisplay("Seelenfackel"));
register("lamp", (new BlockToggleableLight(false)).setHardness(0.3F).setStepSound(SoundType.GLASS)
.setDisplay("Lampe").setTab(CheatTab.TECHNOLOGY));
register("lit_lamp", (new BlockToggleableLight(true)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Lampe"));
register("daylight_detector", new BlockDaylightDetector(false).setDisplay("Tageslichtsensor"));
register("daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor"));
register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));

View file

@ -35,7 +35,6 @@ public abstract class Blocks {
public static final BlockSlab acacia_slab = get("acacia_slab");
public static final BlockStairs acacia_stairs = get("acacia_stairs");
public static final BlockStaticLiquid acid = get("acid");
public static final BlockRailPowered activator_rail = get("activator_rail");
public static final BlockFlower allium = get("allium");
public static final Block aluminium_block = get("aluminium_block");
public static final BlockOre aluminium_ore = get("aluminium_ore");
@ -166,7 +165,6 @@ public abstract class Blocks {
public static final BlockStairs cobblestone_stairs = get("cobblestone_stairs");
public static final BlockWall cobblestone_wall = get("cobblestone_wall");
public static final BlockCocoa cocoa = get("cocoa");
public static final BlockRedstoneComparator comparator = get("comparator");
public static final BlockWorkbench construction_table = get("construction_table");
public static final Block copper_block = get("copper_block");
public static final BlockOre copper_ore = get("copper_ore");
@ -196,7 +194,6 @@ public abstract class Blocks {
public static final BlockDaylightDetector daylight_detector_inverted = get("daylight_detector_inverted");
public static final BlockTallGrass dead_bush = get("dead_bush");
public static final BlockDeadBush deadbush = get("deadbush");
public static final BlockRailDetector detector_rail = get("detector_rail");
public static final Block diamond_block = get("diamond_block");
public static final BlockOre diamond_ore = get("diamond_ore");
public static final Block dirt = get("dirt");
@ -246,7 +243,6 @@ public abstract class Blocks {
public static final BlockGlowstone glowstone = get("glowstone");
public static final Block gold_block = get("gold_block");
public static final BlockOre gold_ore = get("gold_ore");
public static final BlockRailPowered golden_rail = get("golden_rail");
public static final BlockStaticLiquid goo = get("goo");
public static final BlockGrass grass = get("grass");
public static final BlockGravel gravel = get("gravel");
@ -291,7 +287,6 @@ public abstract class Blocks {
public static final BlockSlab jungle_slab = get("jungle_slab");
public static final BlockStairs jungle_stairs = get("jungle_stairs");
public static final BlockLadder ladder = get("ladder");
public static final Block lamp = get("lamp");
public static final Block lapis_block = get("lapis_block");
public static final BlockOre lapis_ore = get("lapis_ore");
public static final BlockDoublePlant large_fern = get("large_fern");
@ -313,8 +308,6 @@ public abstract class Blocks {
public static final BlockWool lime_wool = get("lime_wool");
public static final BlockFurnace lit_furnace = get("lit_furnace");
public static final BlockPumpkin lit_pumpkin = get("lit_pumpkin");
public static final BlockRedstoneLight lit_redstone_lamp = get("lit_redstone_lamp");
public static final BlockRedstoneOre lit_redstone_ore = get("lit_redstone_ore");
public static final Block lithium_block = get("lithium_block");
public static final BlockOre lithium_ore = get("lithium_ore");
public static final BlockCarpet magenta_carpet = get("magenta_carpet");
@ -407,8 +400,6 @@ public abstract class Blocks {
public static final Block potassium_block = get("potassium_block");
public static final BlockOre potassium_ore = get("potassium_ore");
public static final BlockPotato potato = get("potato");
public static final BlockRedstoneComparator powered_comparator = get("powered_comparator");
public static final BlockRedstoneRepeater powered_repeater = get("powered_repeater");
public static final Block praseodymium_block = get("praseodymium_block");
public static final BlockOre praseodymium_ore = get("praseodymium_ore");
public static final BlockPumpkin pumpkin = get("pumpkin");
@ -439,13 +430,9 @@ public abstract class Blocks {
public static final BlockFalling red_sand = get("red_sand");
public static final BlockFlower red_tulip = get("red_tulip");
public static final BlockWool red_wool = get("red_wool");
public static final BlockRedstoneWire redstone = get("redstone");
public static final BlockCompressedPowered redstone_block = get("redstone_block");
public static final BlockRedstoneLight redstone_lamp = get("redstone_lamp");
public static final BlockRedstoneOre redstone_ore = get("redstone_ore");
public static final BlockRedstoneTorch redstone_torch = get("redstone_torch");
public static final BlockMagnetic charged_block = get("charged_block");
public static final BlockOre charge_ore = get("charge_ore");
public static final BlockReed reeds = get("reeds");
public static final BlockRedstoneRepeater repeater = get("repeater");
public static final Block rock = get("rock");
public static final BlockFlower rose = get("rose");
public static final BlockDoublePlant rose_bush = get("rose_bush");
@ -539,12 +526,10 @@ public abstract class Blocks {
public static final BlockTNT tnt_5 = get("tnt_5");
public static final BlockTNT tnt_6 = get("tnt_6");
public static final BlockTNT tnt_7 = get("tnt_7");
public static final BlockTorch torch = get("torch");
public static final BlockTrapDoor trapdoor = get("trapdoor");
public static final BlockTripWireHook tripwire_hook = get("tripwire_hook");
public static final Block tungsten_block = get("tungsten_block");
public static final BlockOre tungsten_ore = get("tungsten_ore");
public static final BlockRedstoneTorch unlit_redstone_torch = get("unlit_redstone_torch");
public static final Block uranium_block = get("uranium_block");
public static final BlockOre uranium_ore = get("uranium_ore");
public static final Block vanadium_block = get("vanadium_block");
@ -599,6 +584,15 @@ public abstract class Blocks {
public static final BlockChest xlarge_chest = get("xlarge_chest");
public static final BlockChest xxlarge_chest = get("xxlarge_chest");
public static final BlockChest xxxlarge_chest = get("xxxlarge_chest");
public static final BlockUnlitTorch torch = get("torch");
public static final BlockLitTorch lit_torch = get("lit_torch");
public static final BlockUnlitTorch tian_torch = get("tian_torch");
public static final BlockLitTorch lit_tian_torch = get("lit_tian_torch");
public static final BlockUnlitTorch soul_torch = get("soul_torch");
public static final BlockLitTorch lit_soul_torch = get("lit_soul_torch");
public static final BlockToggleableLight lamp = get("lamp");
public static final BlockToggleableLight lit_lamp = get("lit_lamp");
public static final BlockWire wire = get("wire");
private static <T extends Block> T get(String id) {
T block = (T)BlockRegistry.byNameExact(id);

View file

@ -33,7 +33,7 @@ public abstract class CraftingRegistry
private static final Object[][] COMPRESSED = new Object[][] {
{Items.emerald_block, new ItemStack(Items.emerald, 9)},
{Items.lapis_block, new ItemStack(Items.lapis_lazuli, 9)},
{Items.redstone_block, new ItemStack(Items.redstone, 9)},
{Items.charged_block, new ItemStack(Items.charged_powder, 9)},
{Items.coal_block, new ItemStack(Items.coal, 9)},
{Items.hay_block, new ItemStack(Items.wheats, 9)},
{Items.slime_block, new ItemStack(Items.slime_ball, 9)}
@ -153,12 +153,11 @@ public abstract class CraftingRegistry
addShapeless(new ItemStack(Items.mossy_cobblestone), Items.cobblestone, Items.vine);
add(new ItemStack(Items.iron_bars, 16), "###", "###", '#', Items.iron_ingot);
add(new ItemStack(Items.glass_pane, 16), "###", "###", '#', Items.glass);
add(new ItemStack(Items.redstone_lamp, 1), " R ", "RGR", " R ", 'R', Items.redstone, 'G', Items.glowstone);
add(new ItemStack(Items.lamp, 1), " R ", "RGR", " R ", 'R', Items.charged_powder, 'G', Items.glowstone);
add(new ItemStack(Items.lamp, 1), " R ", "RGR", " R ", 'R', Items.glass, 'G', Items.glowstone);
add(new ItemStack(Items.effect_generator, 1), "GGG", "GSG", "OOO", 'G', Items.glass, 'S', Items.charge_crystal, 'O', Items.obsidian);
add(new ItemStack(Items.blood_brick, 1), "NN", "NN", 'N', Items.bloodbrick);
add(new ItemStack(Items.coarse_dirt, 4), "DG", "GD", 'D', Items.dirt, 'G', Items.gravel);
add(new ItemStack(Items.lamp, 1), " R ", "RGR", " R ", 'R', Items.glass, 'G', Items.glowstone);
for (DyeColor color : DyeColor.values())
{
@ -235,7 +234,7 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.tripwire_hook, 2), "I", "S", "#", '#', planks, 'S', Items.stick, 'I', Items.iron_ingot);
add(new ItemStack(Items.wooden_button, 1), "#", '#', planks);
add(new ItemStack(Items.wooden_pressure_plate, 1), "##", '#', planks);
add(new ItemStack(Items.piston, 1), "TTT", "#X#", "#R#", '#', Items.cobblestone, 'X', Items.iron_ingot, 'R', Items.redstone, 'T', planks);
add(new ItemStack(Items.piston, 1), "TTT", "#X#", "#R#", '#', Items.cobblestone, 'X', Items.iron_ingot, 'R', Items.charged_powder, 'T', planks);
for(DyeColor color : BlockBed.COLORS) {
add(new ItemStack(ItemRegistry.byName(color.getName() + "_bed"), 1), "###", "XXX", '#', BlockWool.getByColor(color).getItem(), 'X', planks);
}
@ -275,9 +274,6 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.torch, 4), "X", "#", 'X', Items.charcoal, '#', Items.stick);
add(new ItemStack(Items.glass_bottle, 3), "# #", " # ", '#', Items.glass);
add(new ItemStack(Items.rail, 16), "X X", "X#X", "X X", 'X', Items.iron_ingot, '#', Items.stick);
add(new ItemStack(Items.golden_rail, 6), "X X", "X#X", "XRX", 'X', Items.gold_ingot, 'R', Items.redstone, '#', Items.stick);
add(new ItemStack(Items.activator_rail, 6), "XSX", "X#X", "XSX", 'X', Items.iron_ingot, '#', Items.redstone_torch, 'S', Items.stick);
add(new ItemStack(Items.detector_rail, 6), "X X", "X#X", "XRX", 'X', Items.iron_ingot, 'R', Items.redstone, '#', Items.stone_pressure_plate);
add(new ItemStack(Items.minecart, 1), "# #", "###", '#', Items.iron_ingot);
add(new ItemStack(Items.cauldron, 1), "# #", "# #", "###", '#', Items.iron_ingot);
add(new ItemStack(Items.brewing_stand, 1), " B ", "###", '#', Items.cobblestone, 'B', Items.demon_rod);
@ -301,16 +297,13 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.golden_carrot, 1), "###", "#X#", "###", '#', Items.gold_nugget, 'X', Items.carrot);
add(new ItemStack(Items.speckled_melon, 1), "###", "#X#", "###", '#', Items.gold_nugget, 'X', Items.melon);
add(new ItemStack(Items.lever, 1), "X", "#", '#', Items.cobblestone, 'X', Items.stick);
add(new ItemStack(Items.redstone_torch, 1), "X", "#", '#', Items.stick, 'X', Items.redstone);
add(new ItemStack(Items.repeater, 1), "#X#", "III", '#', Items.redstone_torch, 'X', Items.redstone, 'I', Items.stone);
add(new ItemStack(Items.comparator, 1), " # ", "#X#", "III", '#', Items.redstone_torch, 'X', Items.quartz, 'I', Items.stone);
add(new ItemStack(Items.navigator, 1), " # ", "#X#", " # ", '#', Items.iron_ingot, 'X', Items.redstone);
add(new ItemStack(Items.navigator, 1), " # ", "#X#", " # ", '#', Items.iron_ingot, 'X', Items.charged_powder);
add(new ItemStack(Items.stone_button, 1), "#", '#', Items.stone);
add(new ItemStack(Items.stone_pressure_plate, 1), "##", '#', Items.stone);
add(new ItemStack(Items.heavy_weighted_pressure_plate, 1), "##", '#', Items.iron_ingot);
add(new ItemStack(Items.light_weighted_pressure_plate, 1), "##", '#', Items.gold_ingot);
add(new ItemStack(Items.dispenser, 1), "###", "#X#", "#R#", '#', Items.cobblestone, 'X', Items.bow, 'R', Items.redstone);
add(new ItemStack(Items.dropper, 1), "###", "# #", "#R#", '#', Items.cobblestone, 'R', Items.redstone);
add(new ItemStack(Items.dispenser, 1), "###", "#X#", "#R#", '#', Items.cobblestone, 'X', Items.bow, 'R', Items.charged_powder);
add(new ItemStack(Items.dropper, 1), "###", "# #", "#R#", '#', Items.cobblestone, 'R', Items.charged_powder);
add(new ItemStack(Items.sticky_piston, 1), "S", "P", 'S', Items.slime_ball, 'P', Items.piston);
add(new ItemStack(Items.enchanting_table, 1), " B ", "D#D", "###", '#', Items.obsidian, 'B', Items.book, 'D', Items.diamond);
add(new ItemStack(Items.anvil, 1), "III", " i ", "iii", 'I', Items.iron_block, 'i', Items.iron_ingot);
@ -334,9 +327,9 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.mob_spawner, 1), "###", "#X#", "###", 'X', Items.charge_crystal, '#', Items.iron_bars);
add(new ItemStack(Items.dragon_egg, 1), "###", "#X#", "#D#", 'X', Items.charge_crystal, 'D', Items.diamond, '#', Items.obsidian);
add(new ItemStack(Items.red_button, 1), "#", '#', Items.redstone);
add(new ItemStack(Items.red_button, 1), "#", '#', Items.charged_powder);
add(new ItemStack(Items.chick_magnet, 1), "A A", "N N", " C ", 'A', Items.aluminium_ingot, 'N', Items.nickel_ingot, 'C', Items.cobalt_ingot);
add(new ItemStack(Items.magnet, 1), "I I", "N N", " R ", 'I', Items.iron_ingot, 'N', Items.neodymium_ingot, 'R', Items.redstone);
add(new ItemStack(Items.magnet, 1), "I I", "N N", " R ", 'I', Items.iron_ingot, 'N', Items.neodymium_ingot, 'R', Items.charged_powder);
add(new ItemStack(Items.construction_table), "---", "-#-", "---", '#', Items.workbench, '-', Items.iron_ingot);
add(new ItemStack(Items.bedrock), "#####", "#####", "#####", "#####", "#####", '#', Items.obsidian);

View file

@ -207,7 +207,15 @@ public abstract class ItemRegistry {
register("scanner", (new ItemScanner()).setDisplay("Infowerkzeug"));
register("trident", (new ItemTrident()).setDisplay("Geladenes Zepter"));
register("banhammer", (new ItemBanHammer()).setDisplay("Hammer der Verbannung"));
register("key", (new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
ItemKey key;
register("key", (key = new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("black_key", (new ItemKey()).setDisplay("Schwarzer Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("shiny_key", (new ItemKey()).setDisplay("Glänzender Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("rusty_key", (new ItemKey()).setDisplay("Rostiger Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("red_keycard", (new ItemKey()).setDisplay("Rote Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("green_keycard", (new ItemKey()).setDisplay("Grüne Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("blue_keycard", (new ItemKey()).setDisplay("Blaue Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
register("black_keycard", (new ItemKey()).setDisplay("Schwarze Schlüsselkarte").setTab(CheatTab.TOOLS).setMaxAmount(StackSize.L));
for(Pair<Integer, TextColor> sides : ItemDie.DIE_SIDES) {
register("die_" + sides.first(), (new ItemDie(sides.first(), sides.second())).setMaxAmount(StackSize.L));
}
@ -335,6 +343,8 @@ public abstract class ItemRegistry {
register("dynamite" + (z == 0 ? "" : ("_" + z)), (new ItemDynamite(z)).setDisplay("Dynamit" + Util.getTierSuffix(z)).setColor(TextColor.RED));
}
register("chain", (new ItemMagnetic()).setDisplay("Kette").setTab(CheatTab.MATERIALS));
Item chargedPowder = (new ItemMagnetic()).setDisplay("Geladener Staub").setTab(CheatTab.METALS);
register("charged_powder", chargedPowder);
for(OreType ore : OreType.values()) {
Item itm = (new Item()).setDisplay(ore.itemDisplay).setTab(CheatTab.METALS);
@ -376,11 +386,14 @@ public abstract class ItemRegistry {
register("record_delay", (new ItemRecord()).setDisplay("Protokoll #13 - Verzögerung der Umsetzung"));
register("record_extend", (new ItemRecord()).setDisplay("Protokoll #14 - Explosive Erweiterung unseres Labors"));
((BlockOre)BlockRegistry.byName("coal_ore")).setDropItem(new ItemStack(coal), 0);
((BlockOre)BlockRegistry.byName("emerald_ore")).setDropItem(new ItemStack(emerald), 3);
((BlockOre)BlockRegistry.byName("lapis_ore")).setDropItem(new ItemStack(lapis, 4), 4, 2);
((BlockOre)BlockRegistry.byName("quartz_ore")).setDropItem(new ItemStack(quartz), 2);
((BlockOre)BlockRegistry.byName("black_quartz_ore")).setDropItem(new ItemStack(bquartz), 3);
Blocks.coal_ore.setDropItem(new ItemStack(coal), 0);
Blocks.emerald_ore.setDropItem(new ItemStack(emerald), 3);
Blocks.lapis_ore.setDropItem(new ItemStack(lapis, 4), 4, 2);
Blocks.quartz_ore.setDropItem(new ItemStack(quartz), 2);
Blocks.black_quartz_ore.setDropItem(new ItemStack(bquartz), 3);
Blocks.charge_ore.setDropItem(new ItemStack(chargedPowder, 4), 2, 1);
Blocks.iron_door.setKeyItem(key);
Blocks.iron_trapdoor.setKeyItem(key);
Log.SYSTEM.debug("%d Gegenstände registriert", ITEM_MAP.size());
}

View file

@ -23,7 +23,7 @@ import common.item.block.ItemLilyPad;
import common.item.block.ItemMetalBlock;
import common.item.block.ItemPiston;
import common.item.block.ItemPressurePlate;
import common.item.block.ItemRedstone;
import common.item.block.ItemWire;
import common.item.block.ItemSeedFood;
import common.item.block.ItemSeeds;
import common.item.block.ItemSign;
@ -104,7 +104,6 @@ public abstract class Items {
public static final ItemSlab acacia_slab = get("acacia_slab");
public static final ItemBlock acacia_stairs = get("acacia_stairs");
public static final ItemBucket acid_bucket = get("acid_bucket");
public static final ItemBlock activator_rail = get("activator_rail");
public static final Item ahrd_fragment = get("ahrd_fragment");
public static final ItemBlock allium = get("allium");
public static final ItemMetalBlock aluminium_block = get("aluminium_block");
@ -290,7 +289,6 @@ public abstract class Items {
public static final ItemBlock cobblestone_stairs = get("cobblestone_stairs");
public static final ItemWall cobblestone_wall = get("cobblestone_wall");
public static final ItemDye cocoa = get("cocoa");
public static final ItemSmallBlock comparator = get("comparator");
public static final ItemBlock construction_table = get("construction_table");
public static final ItemFood cooked_beef = get("cooked_beef");
public static final ItemFood cooked_chicken = get("cooked_chicken");
@ -326,7 +324,6 @@ public abstract class Items {
public static final ItemBlock daylight_detector = get("daylight_detector");
public static final ItemColored dead_bush = get("dead_bush");
public static final ItemBlock deadbush = get("deadbush");
public static final ItemBlock detector_rail = get("detector_rail");
public static final Item diamond = get("diamond");
public static final ItemAxe diamond_axe = get("diamond_axe");
public static final ItemBlock diamond_block = get("diamond_block");
@ -406,7 +403,6 @@ public abstract class Items {
public static final ItemAppleGold golden_apple = get("golden_apple");
public static final ItemAppleGold charged_apple = get("charged_apple");
public static final ItemFood golden_carrot = get("golden_carrot");
public static final ItemBlock golden_rail = get("golden_rail");
public static final ItemBucket goo_bucket = get("goo_bucket");
public static final ItemColored grass = get("grass");
public static final ItemBlock gravel = get("gravel");
@ -471,9 +467,7 @@ public abstract class Items {
public static final ItemBlock jungle_sapling = get("jungle_sapling");
public static final ItemSlab jungle_slab = get("jungle_slab");
public static final ItemBlock jungle_stairs = get("jungle_stairs");
public static final ItemKey key = get("key");
public static final ItemBlock ladder = get("ladder");
public static final ItemBlock lamp = get("lamp");
public static final ItemBlock lapis_block = get("lapis_block");
public static final ItemDye lapis_lazuli = get("lapis_lazuli");
public static final ItemBlock lapis_ore = get("lapis_ore");
@ -693,13 +687,7 @@ public abstract class Items {
public static final ItemBlock red_sand = get("red_sand");
public static final ItemBlock red_tulip = get("red_tulip");
public static final ItemBlock red_wool = get("red_wool");
public static final ItemRedstone redstone = get("redstone");
public static final ItemBlock redstone_block = get("redstone_block");
public static final ItemBlock redstone_lamp = get("redstone_lamp");
public static final ItemBlock redstone_ore = get("redstone_ore");
public static final ItemBlock redstone_torch = get("redstone_torch");
public static final ItemSmallBlock reeds = get("reeds");
public static final ItemSmallBlock repeater = get("repeater");
public static final ItemBlock rock = get("rock");
public static final ItemBlock rose = get("rose");
public static final ItemDoublePlant rose_bush = get("rose_bush");
@ -825,7 +813,6 @@ public abstract class Items {
public static final ItemBlock tnt_6 = get("tnt_6");
public static final ItemBlock tnt_7 = get("tnt_7");
public static final ItemMinecart tnt_minecart = get("tnt_minecart");
public static final ItemBlock torch = get("torch");
public static final ItemBlock trapdoor = get("trapdoor");
public static final ItemBlock tripwire_hook = get("tripwire_hook");
public static final ItemMetalBlock tungsten_block = get("tungsten_block");
@ -1008,6 +995,22 @@ public abstract class Items {
public static final ItemChest xlarge_chest = get("xlarge_chest");
public static final ItemChest xxlarge_chest = get("xxlarge_chest");
public static final ItemChest xxxlarge_chest = get("xxxlarge_chest");
public static final ItemKey key = get("key");
public static final ItemKey black_key = get("black_key");
public static final ItemKey black_keycard = get("black_keycard");
public static final ItemKey blue_keycard = get("blue_keycard");
public static final ItemKey green_keycard = get("green_keycard");
public static final ItemKey red_keycard = get("red_keycard");
public static final ItemKey rusty_key = get("rusty_key");
public static final ItemKey shiny_key = get("shiny_key");
public static final ItemBlock lamp = get("lamp");
public static final ItemMagnetic charged_powder = get("charged_powder");
public static final ItemWire wire = get("wire");
public static final ItemBlock charged_block = get("charged_block");
public static final ItemBlock charge_ore = get("charge_ore");
public static final ItemBlock torch = get("torch");
public static final ItemBlock soul_torch = get("soul_torch");
public static final ItemBlock tian_torch = get("tian_torch");
private static <T extends Item> T get(String id) {
T item = (T)ItemRegistry.byName(id);

View file

@ -47,7 +47,7 @@ public abstract class SmeltingRegistry
add(Items.coal_ore, new ItemStack(Items.coal), 0.1F);
add(Items.lapis_ore, new ItemStack(Items.lapis_lazuli), 0.2F);
add(Items.quartz_ore, new ItemStack(Items.quartz), 0.2F);
add(Items.redstone_ore, new ItemStack(Items.redstone), 0.7F);
add(Items.charge_ore, new ItemStack(Items.charged_powder), 0.7F);
for(OreType ore : OreType.values()) {
Item item = ItemRegistry.byName(ore.item);

View file

@ -55,7 +55,7 @@ public abstract class TradeRegistry {
new ItemForGem(Items.name_tag, new PriceInfo(20, 22)),
new GemForItem(Items.rotten_flesh, new PriceInfo(36, 40)),
new GemForItem(Items.gold_ingot, new PriceInfo(8, 10)),
new ItemForGem(Items.redstone, new PriceInfo(-4, -1)),
new ItemForGem(Items.charged_powder, new PriceInfo(-4, -1)),
new ItemForGem(Items.ink_sack, new PriceInfo(-2, -1)),
new ItemForGem(Items.charged_orb, new PriceInfo(7, 11)),
new ItemForGem(Items.glowstone, new PriceInfo(-3, -1)),

View file

@ -331,7 +331,7 @@ public abstract class UniverseRegistry {
.addOre(Blocks.gravel.getState(), 8, 0, 33, 0, 256, false)
.addOre(Blocks.rock.getState(), 6, 0, 22, 24, 72, false)
.addOre(Blocks.coal_ore.getState(), 20, 0, 17, 0, 128, false)
.addOre(Blocks.redstone_ore.getState(), 8, 0, 8, 0, 16, false)
.addOre(Blocks.charge_ore.getState(), 8, 0, 8, 0, 16, false)
.addOre(Blocks.lapis_ore.getState(), 1, 0, 7, 16, 16, true)
.addOre(Blocks.diamond_ore.getState(), 1, 0, 8, 0, 16, false)
.addOre(Blocks.ruby_ore.getState(), 1, 0, 4, 12, 8, true)

View file

@ -776,12 +776,12 @@ public abstract class Container
/**
* Like the version that takes an inventory. If the given TileEntity is not an Inventory, 0 is returned instead.
*/
public static int calcRedstone(TileEntity te)
public static int calcSignal(TileEntity te)
{
return te instanceof IInventory ? calcRedstoneFromInventory((IInventory)te) : 0;
return te instanceof IInventory ? calcSignalFrom((IInventory)te) : 0;
}
public static int calcRedstoneFromInventory(IInventory inv)
public static int calcSignalFrom(IInventory inv)
{
if (inv == null)
{

View file

@ -47,7 +47,7 @@ public enum CheatTab {
return Items.hay_block;
}
},
TECHNOLOGY("Redstone & Technik", true) {
TECHNOLOGY("Technik", true) {
protected Item getIconItem() {
return Items.tnt;
}

View file

@ -1,24 +1,27 @@
package common.item.block;
import common.block.Block;
import common.block.tech.BlockRedstoneWire;
import common.block.tech.BlockWire;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.StackSize;
import common.util.BlockPos;
import common.util.Facing;
import common.world.World;
public class ItemRedstone extends Item
public class ItemWire extends Item
{
private final BlockRedstoneWire block;
private final BlockWire block;
public ItemRedstone(BlockRedstoneWire block)
public ItemWire(BlockWire block)
{
this.block = block;
this.setTab(CheatTab.TECHNOLOGY);
this.setDisplay(block.getDisplay());
this.setMaxAmount(StackSize.XL);
}
public Block getBlock()
@ -26,9 +29,6 @@ public class ItemRedstone extends Item
return this.block;
}
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
{
boolean flag = worldIn.getState(pos).getBlock().isReplaceable(worldIn, pos);

View file

@ -1,6 +1,6 @@
package common.item.spawner;
import common.block.tech.BlockRailBase;
import common.block.tech.BlockRail;
import common.entity.item.EntityCart;
import common.entity.item.EntityMinecart;
import common.entity.item.EntityTntCart;
@ -39,7 +39,7 @@ public class ItemMinecart extends Item
{
State iblockstate = worldIn.getState(pos);
if (BlockRailBase.isRailBlock(iblockstate))
if (BlockRail.isRailBlock(iblockstate))
{
if (!worldIn.client)
{
@ -52,7 +52,7 @@ public class ItemMinecart extends Item
// entityitem.setOwner(playerIn.getUser());
// }
// }
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
BlockRail.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRail ? (BlockRail.EnumRailDirection)iblockstate.getValue(BlockRail.SHAPE) : BlockRail.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
@ -91,10 +91,10 @@ public class ItemMinecart extends Item
double d2 = blockpos.getZ() + 0.5 + (double)facing.getFrontOffsetZ() * 1.125D;
BlockPos pos = blockpos.offset(facing);
State iblockstate = world.getState(pos);
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
BlockRail.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRail ? (BlockRail.EnumRailDirection)iblockstate.getValue(BlockRail.SHAPE) : BlockRail.EnumRailDirection.NORTH_SOUTH;
double d3;
if (BlockRailBase.isRailBlock(iblockstate))
if (BlockRail.isRailBlock(iblockstate))
{
if (blockrailbase$enumraildirection.isAscending())
{
@ -107,13 +107,13 @@ public class ItemMinecart extends Item
}
else
{
if (iblockstate.getBlock() != Blocks.air || !BlockRailBase.isRailBlock(world.getState(pos.down())))
if (iblockstate.getBlock() != Blocks.air || !BlockRail.isRailBlock(world.getState(pos.down())))
{
return super.dispenseStack(world, source, position, blockpos, facing, stack);
}
State iblockstate1 = world.getState(pos.down());
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.getValue(((BlockRailBase)iblockstate1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
BlockRail.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRail ? (BlockRail.EnumRailDirection)iblockstate1.getValue(BlockRail.SHAPE) : BlockRail.EnumRailDirection.NORTH_SOUTH;
if (facing != Facing.DOWN && blockrailbase$enumraildirection1.isAscending())
{

View file

@ -58,7 +58,6 @@ public class ItemChargedOrb extends ItemFragile
else
{
worldIn.setState(pos, iblockstate.withProperty(BlockPortalFrame.ORB, Boolean.valueOf(true)), 2);
worldIn.updateComparatorOutputLevel(pos, Blocks.portal_frame);
stack.decrSize();
for (int i = 0; i < 16; ++i)

View file

@ -2,6 +2,7 @@ package common.item.tool;
import common.block.Block;
import common.block.Material;
import common.block.tech.BlockWire;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.ToolMaterial;
@ -37,7 +38,7 @@ public class ItemShears extends Item
public boolean canHarvestBlock(Block blockIn)
{
return blockIn.getMaterial() == Material.FLUFF || blockIn == Blocks.redstone || blockIn == Blocks.string;
return blockIn.getMaterial() == Material.FLUFF || blockIn instanceof BlockWire || blockIn == Blocks.string;
}
public float getStrVsBlock(ItemStack stack, Block state)

View file

@ -6,7 +6,7 @@ import common.block.artificial.BlockDoor;
import common.block.artificial.BlockFence;
import common.block.artificial.BlockFenceGate;
import common.block.artificial.BlockWall;
import common.block.tech.BlockRailBase;
import common.block.tech.BlockRail;
import common.entity.Entity;
import common.init.Blocks;
import common.util.BlockPos;
@ -231,9 +231,9 @@ public class WalkNodeProcessor extends NodeProcessor
flag = true;
}
if (entity.worldObj.getState(mpos).getBlock() instanceof BlockRailBase)
if (entity.worldObj.getState(mpos).getBlock() instanceof BlockRail)
{
if (!(entity.worldObj.getState(blockpos).getBlock() instanceof BlockRailBase) && !(entity.worldObj.getState(blockpos.down()).getBlock() instanceof BlockRailBase))
if (!(entity.worldObj.getState(blockpos).getBlock() instanceof BlockRail) && !(entity.worldObj.getState(blockpos.down()).getBlock() instanceof BlockRail))
{
return -3;
}

View file

@ -3,7 +3,6 @@ package common.tileentity;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.log.Log;
import common.network.Packet;
import common.tags.TagObject;
@ -94,11 +93,6 @@ public abstract class TileEntity
this.blockState = this.worldObj.getState(this.pos);
if(!this.worldObj.client)
((AWorldServer)this.worldObj).markChunkDirty(this.pos);
if (this.getBlockType() != Blocks.air)
{
this.worldObj.updateComparatorOutputLevel(this.pos, this.getBlockType());
}
}
}
@ -184,4 +178,12 @@ public abstract class TileEntity
}
public abstract int getColor();
public boolean hasPower() {
return true;
}
public boolean decrPower() {
return true;
}
}

View file

@ -1,5 +1,6 @@
package common.tileentity;
import common.block.tech.BlockDispenser;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
@ -8,12 +9,19 @@ import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.rng.Random;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.Facing;
import common.vars.Vars;
import common.world.State;
import common.world.World;
import java.util.List;
public class TileEntityDispenser extends TileEntityInventory
public class TileEntityDispenser extends TileEntityInventory implements ITickable
{
private static final Random RNG = new Random();
private ItemStack[] stacks = new ItemStack[9];
private int cooldown = 0;
/**
* Returns the number of slots in the inventory.
@ -133,6 +141,7 @@ public class TileEntityDispenser extends TileEntityInventory
public void readTags(TagObject compound)
{
super.readTags(compound);
this.cooldown = compound.getInt("Cooldown");
List<TagObject> nbttaglist = compound.getList("Items");
this.stacks = new ItemStack[this.getSizeInventory()];
@ -151,6 +160,7 @@ public class TileEntityDispenser extends TileEntityInventory
public void writeTags(TagObject compound)
{
super.writeTags(compound);
compound.setInt("Cooldown", this.cooldown);
List<TagObject> nbttaglist = Lists.newArrayList();
for (int i = 0; i < this.stacks.length; ++i)
@ -229,4 +239,54 @@ public class TileEntityDispenser extends TileEntityInventory
public int getColor() {
return 0xffbf00;
}
protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(BlockDispenser.FACING);
ItemStack nstack = stack.getItem().dispenseStack(world, world.getTileEntity(pos), BlockDispenser.getDispensePosition(pos, facing), pos, facing, stack);
int id = stack.getItem().getDispenseSoundId();
if(id != 0)
world.playAuxSFX(id, pos, 0);
world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return nstack;
}
protected void dispense(World worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
return;
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if(itemstack != null) {
ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
tileentitydispenser.setInventorySlotContents(i, itemstack1.isEmpty() ? null : itemstack1);
}
}
}
}
public void update() {
if(this.worldObj != null && !this.worldObj.client) {
if (this.cooldown <= 0)
{
State state = this.getBlockState();
if(!(state.getBlock() instanceof BlockDispenser) || !this.decrPower())
return;
this.dispense(this.worldObj, this.pos);
this.cooldown = Vars.dispenserDelay;
}
else {
this.cooldown--;
}
}
}
}

View file

@ -1,5 +1,77 @@
package common.tileentity;
import common.block.tech.BlockDispenser;
import common.inventory.IInventory;
import common.item.ItemStack;
import common.util.BlockPos;
import common.util.Facing;
import common.world.World;
public class TileEntityDropper extends TileEntityDispenser
{
protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(BlockDispenser.FACING);
BlockDispenser.dispense(world, 6.0, facing, BlockDispenser.getDispensePosition(pos, facing), stack.split(1));
world.playAuxSFX(1000, pos, 0);
world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return stack;
}
protected void dispense(World worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
return;
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if (itemstack != null)
{
Facing enumfacing = (Facing)worldIn.getState(pos).getValue(BlockDispenser.FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
if (itemstack1 != null && itemstack1.isEmpty())
{
itemstack1 = null;
}
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().split(1), enumfacing.getOpposite());
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (itemstack1.decrSize())
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
}

View file

@ -212,7 +212,7 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
if (!this.isOnTransferCooldown())
{
State state = this.getBlockState();
if(!(state.getBlock() instanceof BlockHopper) || !state.getValue(BlockHopper.ENABLED))
if(!(state.getBlock() instanceof BlockHopper) || !this.decrPower())
return false;
boolean flag = false;

View file

@ -249,8 +249,8 @@ public abstract class Vars {
public static int healChance = 5;
@Var(name = "hopperCooldown", min = 0, max = 160)
public static int hopperDelay = 2;
@Var(name = "hopperCartCooldown", min = 0, max = 160)
public static int hopperCartDelay = 1;
@Var(name = "dispenserCooldown", min = 0, max = 160)
public static int dispenserDelay = 1;
@Var(name = "xpCooldown", min = 0, max = 10)
public static int xpDelay = 0; // 2
@Var(name = "eggLayTime")
@ -263,6 +263,8 @@ public abstract class Vars {
public static int distance = 8;
@Var(name = "timeFlow", min = 1)
public static int timeFlow = 1;
@Var(name = "torchBurnoutChance")
public static int torchBurnout = 30;
@Var(name = "gravity", min = -10.0f, max = 10.0f)
public static float gravity = 1.0f;

View file

@ -237,10 +237,6 @@ public abstract class World implements IWorldAccess {
if(!this.client && (flags & 1) != 0) {
this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock());
if(block.hasSignalProcessing()) {
this.updateComparatorOutputLevel(pos, block);
}
}
return true;
@ -1835,89 +1831,6 @@ public abstract class World implements IWorldAccess {
return 63;
}
private int getStrongPower(BlockPos pos, Facing direction) {
State iblockstate = this.getState(pos);
return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction);
}
private int getStrongPower(BlockPos pos) {
int i = 0;
i = Math.max(i, this.getStrongPower(pos.down(), Facing.DOWN));
if(i >= 15) {
return i;
}
else {
i = Math.max(i, this.getStrongPower(pos.up(), Facing.UP));
if(i >= 15) {
return i;
}
else {
i = Math.max(i, this.getStrongPower(pos.north(), Facing.NORTH));
if(i >= 15) {
return i;
}
else {
i = Math.max(i, this.getStrongPower(pos.south(), Facing.SOUTH));
if(i >= 15) {
return i;
}
else {
i = Math.max(i, this.getStrongPower(pos.west(), Facing.WEST));
if(i >= 15) {
return i;
}
else {
i = Math.max(i, this.getStrongPower(pos.east(), Facing.EAST));
return i >= 15 ? i : i;
}
}
}
}
}
}
public boolean isSidePowered(BlockPos pos, Facing side) {
return this.getRedstonePower(pos, side) > 0;
}
public int getRedstonePower(BlockPos pos, Facing facing) {
State iblockstate = this.getState(pos);
Block block = iblockstate.getBlock();
return block.isNormalCube() ? this.getStrongPower(pos) : block.getWeakPower(this, pos, iblockstate, facing);
}
public boolean isBlockPowered(BlockPos pos) {
return this.getRedstonePower(pos.down(), Facing.DOWN) > 0 ? true
: (this.getRedstonePower(pos.up(), Facing.UP) > 0 ? true
: (this.getRedstonePower(pos.north(), Facing.NORTH) > 0 ? true
: (this.getRedstonePower(pos.south(), Facing.SOUTH) > 0 ? true
: (this.getRedstonePower(pos.west(), Facing.WEST) > 0 ? true
: this.getRedstonePower(pos.east(), Facing.EAST) > 0))));
}
public int isBlockIndirectlyGettingPowered(BlockPos pos) {
int i = 0;
for(Facing enumfacing : Facing.values()) {
int j = this.getRedstonePower(pos.offset(enumfacing), enumfacing);
if(j >= 15) {
return 15;
}
if(j > i) {
i = j;
}
}
return i;
}
public EntityNPC getClosestPlayerToEntity(Entity entityIn, double distance) {
return this.getClosestPlayer(entityIn.posX, entityIn.posY, entityIn.posZ, distance);
}
@ -2076,47 +1989,10 @@ public abstract class World implements IWorldAccess {
return Math.abs(gravity) < 0.075 ? 0.0 : gravity;
}
// public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
// }
//
// public WorldSavedData loadItemData(Class<? extends WorldSavedData> clazz, String dataID) {
// return null;
// }
//
// public int getNextMapId() {
// return 0;
// }
public final void playAuxSFX(int type, BlockPos pos, int data) {
this.playAuxSFX(null, type, pos, data);
}
public void updateComparatorOutputLevel(BlockPos pos, Block blockIn) {
for(Facing enumfacing : Facing.Plane.HORIZONTAL) {
BlockPos blockpos = pos.offset(enumfacing);
if(this.isBlockLoaded(blockpos)) {
State iblockstate = this.getState(blockpos);
if(Blocks.comparator.isAssociated(iblockstate.getBlock())) {
iblockstate.getBlock().onNeighborBlockChange(this, blockpos, iblockstate, blockIn);
}
else if(iblockstate.getBlock().isNormalCube()) {
blockpos = blockpos.offset(enumfacing);
iblockstate = this.getState(blockpos);
if(Blocks.comparator.isAssociated(iblockstate.getBlock())) {
iblockstate.getBlock().onNeighborBlockChange(this, blockpos, iblockstate, blockIn);
}
}
}
}
}
// public DifficultyInstance getDifficultyForLocation(BlockPos pos) {
// return null;
// }
public void scheduleUpdate(BlockPos pos, Block blockIn, int delay) {
}
@ -2127,14 +2003,6 @@ public abstract class World implements IWorldAccess {
this.spawnParticle(particleType, xCoord, yCoord, zCoord, 0);
}
// public Difficulty getDifficulty() {
// return this.difficulty;
// }
// public void setDifficulty(Difficulty diff) {
// this.difficulty = diff;
// }
public abstract Chunk getChunk(int x, int z);
public abstract void markBlockForUpdate(BlockPos pos);
protected abstract void notifyLightSet(BlockPos pos);
@ -2142,7 +2010,6 @@ public abstract class World implements IWorldAccess {
public abstract void playSound(SoundEvent sound, double x, double y, double z, float volume);
protected abstract void onEntityAdded(Entity entityIn);
protected abstract void onEntityRemoved(Entity entityIn);
// public abstract void broadcastSound(int soundID, BlockPos pos, int data);
public abstract void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data);
public abstract void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress);
}