This commit is contained in:
Sen 2025-07-16 16:01:56 +02:00
parent 5a69c0545b
commit cf37d48292
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
122 changed files with 633 additions and 2384 deletions

View file

@ -1082,7 +1082,7 @@ public class Client implements IThreadListener {
if(this.pointed != null && this.pointed.block != null) {
State state = this.world.getState(this.pointed.block);
if(state.getBlock() != Blocks.air) {
Item item = state.getBlock().getItem(this.world, this.pointed.block);
Item item = state.getBlock().getItem();
if(item != null) {
GL11.glPopMatrix();
GL11.glPushMatrix();
@ -1450,14 +1450,12 @@ public class Client implements IThreadListener {
return;
}
item = block.getItem(this.world, blockpos);
item = block.getItem();
if (item == null)
{
return;
}
Block block1 = item instanceof ItemBlock && !block.isPickStrict() ? item.getBlock() : block;
}
else
{

View file

@ -88,7 +88,6 @@ import common.packet.SPacketTabComplete;
import common.packet.SPacketUpdateEntityTags;
import common.packet.SPacketAnimation;
import common.packet.SPacketBiome;
import common.packet.SPacketBlockAction;
import common.packet.SPacketBlockBreakAnim;
import common.packet.SPacketBlockChange;
import common.packet.SPacketCamera;
@ -1376,18 +1375,6 @@ public class ClientPlayer implements IClientPlayer
this.gm.show(null);
}
/**
* Triggers Block.onBlockEventReceived, which is implemented in BlockPistonBase for extension/retraction, BlockNote
* for setting the instrument (including audiovisual feedback) and in BlockContainer to set the number of players
* accessing a (Ender)Chest
*/
public void handleBlockAction(SPacketBlockAction packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
if(packetIn.getBlockType() != null)
this.gm.world.addBlockEvent(packetIn.getBlockPosition(), packetIn.getBlockType(), packetIn.getData1(), packetIn.getData2());
}
/**
* Updates all registered IWorldAccess instances with destroyBlockInWorldPartially
*/

View file

@ -21,6 +21,7 @@ import client.renderer.tileentity.TileEntityRendererDispatcher;
import client.renderer.tileentity.TileEntitySpecialRenderer;
import client.world.WorldClient;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.collect.Maps;
import common.collect.Sets;
import common.model.BlockLayer;
@ -153,7 +154,7 @@ public class RenderChunk
lvt_10_1_.func_178606_a(blockpos$mutableblockpos);
}
if (block.hasTileEntity())
if (block instanceof ITileEntityProvider)
{
TileEntity tileentity = iblockaccess.getTileEntity(new BlockPos(blockpos$mutableblockpos));
TileEntitySpecialRenderer<TileEntity> tileentityspecialrenderer = TileEntityRendererDispatcher.instance.<TileEntity>getSpecialRenderer(tileentity);

View file

@ -2,7 +2,6 @@ package client.renderer.tileentity;
import common.block.tech.BlockChest;
import common.item.ItemStack;
import common.item.block.ItemChest;
import common.tileentity.TileEntityChest;
import common.util.Facing;
import common.world.State;
@ -23,8 +22,8 @@ public class TileEntityItemStackRenderer {
};
public void renderByItem(ItemStack stack) {
if(stack.getItem() instanceof ItemChest chest) {
this.state = chest.getBlock().getState().withProperty(BlockChest.FACING, Facing.SOUTH);
if(stack.getItem() != null && stack.getItem().getBlock() instanceof BlockChest chest) {
this.state = chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH);
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F);
}
}

View file

@ -1,80 +0,0 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.DefaultVertexFormats;
import client.renderer.GlState;
import client.renderer.ItemRenderer;
import client.renderer.RenderBuffer;
import client.renderer.Tessellator;
import client.renderer.texture.TextureMap;
import common.block.Block;
import common.block.tech.BlockPistonBase;
import common.block.tech.BlockPistonHead;
import common.init.Blocks;
import common.tileentity.TileEntityPiston;
import common.util.BlockPos;
import common.world.State;
import common.world.World;
public class TileEntityPistonRenderer extends TileEntitySpecialRenderer<TileEntityPiston>
{
private final BlockRenderer blockRenderer = Client.CLIENT.getBlockRendererDispatcher();
public void renderTileEntityAt(TileEntityPiston te, double x, double y, double z, float partialTicks, int destroyStage)
{
BlockPos blockpos = te.getPos();
State iblockstate = te.getPistonState();
Block block = iblockstate.getBlock();
if (block != Blocks.air && te.getProgress(partialTicks) < 1.0F)
{
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
this.bindTexture(TextureMap.BLOCKS);
ItemRenderer.disableStandardItemLighting();
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlState.enableBlend();
GlState.disableCull();
// if (Game.getGame().isAmbientOcclusionEnabled())
// {
// GlState.shadeModel(GL11.GL_SMOOTH);
// }
// else
// {
GlState.shadeModel(GL11.GL_FLAT);
// }
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldrenderer.setTranslation((double)((float)x - (float)blockpos.getX() + te.getOffsetX(partialTicks)), (double)((float)y - (float)blockpos.getY() + te.getOffsetY(partialTicks)), (double)((float)z - (float)blockpos.getZ() + te.getOffsetZ(partialTicks)));
World world = this.getWorld();
if (block == Blocks.piston_head && te.getProgress(partialTicks) < 0.5F)
{
iblockstate = iblockstate.withProperty(BlockPistonHead.SHORT, Boolean.valueOf(true));
this.blockRenderer.renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate, world, blockpos), iblockstate, blockpos, worldrenderer, true);
}
else if (te.shouldPistonHeadBeRendered() && !te.isExtending())
{
BlockPistonHead.EnumPistonType blockpistonextension$enumpistontype = block == Blocks.sticky_piston ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT;
State iblockstate1 = Blocks.piston_head.getState().withProperty(BlockPistonHead.TYPE, blockpistonextension$enumpistontype).withProperty(BlockPistonHead.FACING, iblockstate.getValue(BlockPistonBase.FACING));
iblockstate1 = iblockstate1.withProperty(BlockPistonHead.SHORT, Boolean.valueOf(te.getProgress(partialTicks) >= 0.5F));
this.blockRenderer.renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate1, world, blockpos), iblockstate1, blockpos, worldrenderer, true);
worldrenderer.setTranslation((double)((float)x - (float)blockpos.getX()), (double)((float)y - (float)blockpos.getY()), (double)((float)z - (float)blockpos.getZ()));
iblockstate.withProperty(BlockPistonBase.EXTENDED, Boolean.valueOf(true));
this.blockRenderer.renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate, world, blockpos), iblockstate, blockpos, worldrenderer, true);
}
else
{
this.blockRenderer.renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate, world, blockpos), iblockstate, blockpos, worldrenderer, false);
}
worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
Tessellator.draw();
ItemRenderer.enableStandardItemLighting();
}
}
}

View file

@ -11,7 +11,6 @@ import common.entity.Entity;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntityPiston;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.world.World;
@ -47,7 +46,6 @@ public class TileEntityRendererDispatcher
{
this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
this.mapSpecialRenderers.put(TileEntityDisplay.class, new TileEntityDisplayRenderer());
this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())

View file

@ -22,6 +22,7 @@ import common.rng.Random;
import common.sound.MovingSoundMinecart;
import common.sound.PositionedSound;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos;
import common.util.ChunkPos;
import common.util.ExtMath;
@ -658,6 +659,12 @@ public class WorldClient extends AWorldClient
case 2005:
ItemDye.spawnBonemealParticles(this, blockPosIn, data);
break;
case 2016:
TileEntity te = this.getTileEntity(blockPosIn);
if(te instanceof TileEntityChest chest)
chest.setUsing(data);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

View file

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 237 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 192 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 209 B

Before After
Before After

View file

@ -173,8 +173,9 @@ public class Block {
protected boolean axeHarvest;
protected boolean shovelHarvest;
protected boolean ticked;
protected boolean hasTile;
protected boolean flatItemTexture;
private boolean flatBlockTexture;
private boolean flatItemTexture;
private boolean itemColored;
protected int lightOpacity;
protected int lightValue;
protected int miningLevel;
@ -367,11 +368,21 @@ public class Block {
return this;
}
protected Block setFlatBlockTexture() {
this.flatBlockTexture = true;
return this;
}
protected Block setFlatItemTexture() {
this.flatItemTexture = true;
return this;
}
protected Block setItemColored() {
this.itemColored = true;
return this;
}
public Block setDisplay(String name) {
this.display = name;
return this;
@ -507,10 +518,6 @@ public class Block {
return this.ticked;
}
public boolean hasTileEntity() {
return this.hasTile;
}
protected final void setBlockBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
this.minX = (double)minX;
this.minY = (double)minY;
@ -614,14 +621,6 @@ public class Block {
public void onBlockRemoved(AWorldServer world, BlockPos pos, State state) {
}
public int quantityDropped(Random random) {
return 1;
}
public Item getItemDropped(State state, Random rand, int fortune) {
return this.getItem() instanceof ItemBlock item ? item : null;
}
public float getPlayerRelativeBlockHardness(EntityNPC playerIn, World worldIn, BlockPos pos) {
float f = this.getBlockHardness(worldIn, pos);
return f < 0.0F ? 0.0F
@ -629,48 +628,6 @@ public class Block {
: playerIn.getToolDigEfficiency(this) / f / 30.0F);
}
public final void dropBlockAsItem(World worldIn, BlockPos pos, State state, int forture) {
this.dropBlockAsItemWithChance(worldIn, pos, state, 1.0F, forture);
}
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, State state, float chance, int fortune) {
if(!worldIn.client) {
int i = this.quantityDroppedWithBonus(fortune, worldIn.rand);
for(int j = 0; j < i; ++j) {
if(worldIn.rand.floatv() <= chance) {
Item item = this.getItemDropped(state, worldIn.rand, fortune);
if(item != null) {
spawnAsEntity(worldIn, pos, new ItemStack(item));
}
}
}
}
}
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack) {
if(!worldIn.client && Vars.blockDrop) {
float f = 0.5F;
double d0 = (double)(worldIn.rand.floatv() * f) + (double)(1.0F - f) * 0.5D;
double d1 = (double)(worldIn.rand.floatv() * f) + (double)(1.0F - f) * 0.5D;
double d2 = (double)(worldIn.rand.floatv() * f) + (double)(1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, stack);
entityitem.setDefaultPickupDelay();
worldIn.spawnEntityInWorld(entityitem);
}
}
protected void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
if(!worldIn.client && Vars.blockXP) {
while(amount > 0) {
int i = EntityXp.getXPSplit(amount);
amount -= i;
worldIn.spawnEntityInWorld(new EntityXp(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, i));
}
}
}
public float getExplosionResistance(Entity exploder) {
return this.blockResistance / 5.0F;
}
@ -792,10 +749,6 @@ public class Block {
return BlockLayer.SOLID;
}
public boolean canReplace(World worldIn, BlockPos pos, Facing side, ItemStack stack) {
return this.canPlaceBlockOnSide(worldIn, pos, side);
}
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, Facing side) {
return this.canPlaceBlockAt(worldIn, pos);
}
@ -867,35 +820,11 @@ public class Block {
public void setBlockBoundsForItemRender() {
}
public void harvestBlock(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te) {
if(this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player)) {
ItemStack itemstack = this.createStackedBlock(state);
if(itemstack != null) {
spawnAsEntity(worldIn, pos, itemstack);
}
}
else {
int i = EnchantmentHelper.getFortuneModifier(player);
this.dropBlockAsItem(worldIn, pos, state, i);
}
}
public boolean canSilkHarvest() {
return this.isFullCube() && !this.hasTile;
return this.isFullCube() && !(this instanceof ITileEntityProvider);
}
public ItemStack createStackedBlock(State state) {
Item item = this.getItem();
// TODO: data
return item instanceof ItemBlock ? new ItemStack(item) : null;
}
public int quantityDroppedWithBonus(int fortune, Random random) {
return this.quantityDropped(random);
}
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack) {
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer) {
}
public boolean canSpawnInBlock() {
@ -906,10 +835,6 @@ public class Block {
return this.display;
}
public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam) {
return false;
}
public int getMobilityFlag() {
return this.material.getMobility();
}
@ -922,10 +847,6 @@ public class Block {
entityIn.motionY = 0.0D;
}
public Item getItem(World worldIn, BlockPos pos) {
return this.getItem() instanceof ItemBlock item ? item : null;
}
public CheatTab getTab() {
return this.tab;
}
@ -936,10 +857,6 @@ public class Block {
public void fillWithRain(World worldIn, BlockPos pos) {
}
public boolean isPickStrict() {
return false;
}
public boolean requiresUpdates() {
return true;
}
@ -1039,7 +956,7 @@ public class Block {
}
protected Item getItemToRegister() {
return new ItemBlock(this, this.flatItemTexture ? "" : null);
return new ItemBlock(this);
}
public final Item registerItem() {
@ -1051,12 +968,78 @@ public class Block {
this.item = item;
return item;
}
public final Item getItem() {
public Item getItem() {
return this.item;
}
public boolean canConnectToWire() {
public Item getItemDropped(State state, Random rand, int fortune) {
return this.getItem();
}
protected int quantityDropped(Random random) {
return 1;
}
protected int quantityDroppedWithBonus(int fortune, Random random) {
return this.quantityDropped(random);
}
public void harvestBlock(World world, EntityNPC player, BlockPos pos, State state, TileEntity te) {
if(this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player)) {
Item item = this.getItem();
if(item != null)
spawnAsEntity(world, pos, new ItemStack(item));
}
else {
int fortune = EnchantmentHelper.getFortuneModifier(player);
this.dropBlockAsItem(world, pos, state, fortune);
}
}
public final void dropBlockAsItem(World worldIn, BlockPos pos, State state, int fortune) {
this.dropBlockAsItemWithChance(worldIn, pos, state, 1.0F, fortune);
}
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, State state, float chance, int fortune) {
if(!worldIn.client) {
int i = this.quantityDroppedWithBonus(fortune, worldIn.rand);
for(int j = 0; j < i; ++j) {
if(worldIn.rand.floatv() <= chance) {
Item item = this.getItemDropped(state, worldIn.rand, fortune);
if(item != null) {
spawnAsEntity(worldIn, pos, new ItemStack(item));
}
}
}
}
}
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack) {
if(!worldIn.client && Vars.blockDrop) {
float f = 0.5F;
double d0 = (double)(worldIn.rand.floatv() * f) + (double)(1.0F - f) * 0.5D;
double d1 = (double)(worldIn.rand.floatv() * f) + (double)(1.0F - f) * 0.5D;
double d2 = (double)(worldIn.rand.floatv() * f) + (double)(1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, stack);
entityitem.setDefaultPickupDelay();
worldIn.spawnEntityInWorld(entityitem);
}
}
protected void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
if(!worldIn.client && Vars.blockXP) {
while(amount > 0) {
int i = EntityXp.getXPSplit(amount);
amount -= i;
worldIn.spawnEntityInWorld(new EntityXp(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, i));
}
}
}
public boolean canConnectToWire(State state) {
return false;
}
@ -1067,4 +1050,20 @@ public class Block {
public double powerTick(World worldIn, BlockPos pos, State state, Random rand, double voltage, double currentLimit) {
return 0.0;
}
public final boolean hasBlockFlatTexture() {
return this.flatBlockTexture;
}
public final boolean hasItemFlatTexture() {
return this.flatItemTexture;
}
public final boolean isItemColored() {
return this.itemColored;
}
public String getItemTexture(String name) {
return name;
}
}

View file

@ -1,39 +0,0 @@
package common.block;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public abstract class BlockContainer extends Block implements ITileEntityProvider {
public BlockContainer(Material material) {
super(material);
this.hasTile = true;
}
private boolean isInvalidNeighbor(World world, BlockPos pos, Facing face) {
return world.getState(pos.offset(face)).getBlock().getMaterial() == Material.BLOCKING;
}
protected boolean hasInvalidNeighbor(World world, BlockPos pos) {
return this.isInvalidNeighbor(world, pos, Facing.NORTH) || this.isInvalidNeighbor(world, pos, Facing.SOUTH)
|| this.isInvalidNeighbor(world, pos, Facing.WEST) || this.isInvalidNeighbor(world, pos, Facing.EAST);
}
public int getRenderType() {
return -1;
}
public void onBlockRemoved(AWorldServer world, BlockPos pos, State state) {
super.onBlockRemoved(world, pos, state);
world.removeTileEntity(pos);
}
public boolean onBlockEventReceived(World world, BlockPos pos, State state, int id, int param) {
super.onBlockEventReceived(world, pos, state, id, param);
TileEntity tile = world.getTileEntity(pos);
return tile == null ? false : tile.receiveClientEvent(id, param);
}
}

View file

@ -6,7 +6,6 @@ import common.block.Material;
import common.color.DyeColor;
import common.color.TextColor;
import common.entity.npc.EntityNPC;
import common.init.ItemRegistry;
import common.item.Item;
import common.item.block.ItemBed;
import common.model.BlockLayer;
@ -113,7 +112,7 @@ public class BlockBed extends Block implements Rotatable {
}
public Item getItemDropped(State state, Random rand, int fortune) {
return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : ItemRegistry.byName(this.color.getName() + "_bed");
return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : super.getItemDropped(state, rand, fortune);
}
private void setBedBounds() {
@ -168,10 +167,6 @@ public class BlockBed extends Block implements Rotatable {
return BlockLayer.CUTOUT;
}
public Item getItem(World worldIn, BlockPos pos) {
return ItemRegistry.byName(this.color.getName() + "_bed");
}
// public void onBlockHarvested(World worldIn, BlockPos pos, State state, EntityNPC player) {
// if(player.creative && state.getValue(PART) == BlockBed.EnumPartType.HEAD) {
// BlockPos blockpos = pos.offset(((Facing)state.getValue(FACING)).getOpposite());

View file

@ -22,7 +22,7 @@ public class BlockBookshelf extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 3;
}

View file

@ -3,10 +3,7 @@ package common.block.artificial;
import common.block.Block;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.block.ItemSmallBlock;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -95,6 +92,7 @@ public class BlockCake extends Block
super(Material.SOFT);
this.setDefaultState(this.getBaseState().withProperty(BITES, Integer.valueOf(0)));
// this.setTickRandomly(true);
this.setFlatItemTexture();
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
@ -191,7 +189,7 @@ public class BlockCake extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}
@ -204,11 +202,6 @@ public class BlockCake extends Block
return null;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.cake;
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
@ -222,8 +215,4 @@ public class BlockCake extends Block
public Model getModel(ModelProvider provider, String name, State state) {
return cake_slices[state.getValue(BITES)];
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Kuchen").setTab(CheatTab.DECORATION);
}
}

View file

@ -227,7 +227,7 @@ public class BlockDoor extends Block implements Rotatable {
}
public Item getItemDropped(State state, Random rand, int fortune) {
return state.getValue(HALF) == EnumDoorHalf.UPPER ? null : this.getItem();
return state.getValue(HALF) == EnumDoorHalf.UPPER ? null : super.getItemDropped(state, rand, fortune);
}
public HitPosition collisionRayTrace(World world, BlockPos pos, Vec3 start, Vec3 end) {
@ -243,10 +243,6 @@ public class BlockDoor extends Block implements Rotatable {
return 1;
}
public Item getItem(World world, BlockPos pos) {
return this.getItem();
}
public BlockLayer getBlockLayer() {
return BlockLayer.CUTOUT;
}

View file

@ -73,7 +73,7 @@ public class BlockFloorPortal extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}
@ -99,11 +99,6 @@ public class BlockFloorPortal extends Block
worldIn.spawnParticle(ParticleType.SMOKE, d0, d1, d2);
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
// /**
// * Get the MapColor for this Block and the given BlockState
// */

View file

@ -14,7 +14,6 @@ import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemBlock;
import common.item.block.ItemSmallBlock;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -111,6 +110,7 @@ public class BlockFlowerPot extends Block
super(Material.SMALL);
this.content = content;
this.setBlockBoundsForItemRender();
this.setFlatItemTexture();
POTS.add(this);
}
@ -178,16 +178,6 @@ public class BlockFlowerPot extends Block
}
}
public Item getItem(World worldIn, BlockPos pos)
{
return worldIn.getState(pos).getBlock() == this && this.content != null ? this.content.getItem() : Items.flowerpot;
}
public boolean isPickStrict()
{
return true;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && worldIn.isBlockSolid(pos.down());
@ -270,6 +260,6 @@ public class BlockFlowerPot extends Block
}
protected Item getItemToRegister() {
return this.content == null ? new ItemSmallBlock(this).setDisplay("Blumentopf").setTab(CheatTab.DECORATION) : null;
return this.content == null ? super.getItemToRegister() : null;
}
}

View file

@ -18,7 +18,7 @@ public class BlockGlass extends Block {
this.setTab(CheatTab.BLOCKS);
}
public int quantityDropped(Random rand) {
protected int quantityDropped(Random rand) {
return 0;
}

View file

@ -26,15 +26,6 @@ public class BlockHay extends BlockRotatedPillar
return new Property[] {AXIS};
}
public ItemStack createStackedBlock(State state)
{
return new ItemStack(this.getItem());
}
/**
* 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 super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, placer).withProperty(AXIS, facing.getAxis());

View file

@ -24,7 +24,7 @@ public class BlockLadder extends Block implements Rotatable
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.WOOD);
this.setFlatItemTexture();
this.setFlatBlockTexture();
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)

View file

@ -29,15 +29,13 @@ public class BlockPane extends Block
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west");
private final boolean canDrop;
public BlockPane(Material materialIn, boolean canDrop)
public BlockPane(Material materialIn)
{
super(materialIn);
this.setDefaultState(this.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
this.canDrop = canDrop;
this.setTab(CheatTab.BLOCKS);
this.setFlatItemTexture();
this.setFlatBlockTexture();
}
/**
@ -54,7 +52,7 @@ public class BlockPane extends Block
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return !this.canDrop ? null : super.getItemDropped(state, rand, fortune);
return this.material != Material.SOLID ? null : super.getItemDropped(state, rand, fortune);
}
/**
@ -210,12 +208,12 @@ public class BlockPane extends Block
return this.material == Material.SOLID;
}
protected String getPaneBase(State state) {
return "glass";
protected String getPaneBase() {
return this.material == Material.SOLID ? "iron_bars" : "glass";
}
protected String getPaneEdge(State state) {
return "glass_pane";
protected String getPaneEdge() {
return this.material == Material.SOLID ? "iron_bars" : "glass_pane";
}
public Model getModel(ModelProvider provider, String name, State state) {
@ -224,9 +222,11 @@ public class BlockPane extends Block
boolean w = state.getValue(WEST);
boolean e = state.getValue(EAST);
int sides = (n ? 1 : 0) + (s ? 1 : 0) + (w ? 1 : 0) + (e ? 1 : 0);
if(this.canDrop) {
String pane = this.getPaneBase();
String edge = this.getPaneEdge();
if(this.material == Material.SOLID) {
if(sides == 0 || sides == 4)
return provider.getModel(name)
return provider.getModel(pane)
.add(8, 0, 0, 8, 16, 16)
.w().uv(0, 0, 16, 16).noCull()
.e().uv(0, 0, 16, 16).noCull()
@ -249,7 +249,7 @@ public class BlockPane extends Block
.d().uv(9, 0, 7, 7).rot(90).noCull()
.u().uv(7, 0, 9, 7).rot(90).noCull();
else if(sides == 1)
return provider.getModel(name)
return provider.getModel(pane)
.add(8, 0, 0, 8, 16, 8)
.w().uv(8, 0, 16, 16).noCull()
.e().uv(8, 0, 16, 16).noCull()
@ -261,7 +261,7 @@ public class BlockPane extends Block
.u().uv(7, 0, 9, 9).noCull()
.rotate(n ? ModelRotation.X0_Y0 : (s ? ModelRotation.X0_Y180 : (w ? ModelRotation.X0_Y270 : ModelRotation.X0_Y90)));
else if(sides == 2 && ((e != w) || (n != s)))
return provider.getModel(name)
return provider.getModel(pane)
.add(8, 0, 0, 8, 16, 8)
.w().uv(0, 0, 8, 16).noCull()
.e().uv(8, 0, 16, 16).noCull()
@ -281,7 +281,7 @@ public class BlockPane extends Block
.rotate(n && e ? ModelRotation.X0_Y0 : (s && w ? ModelRotation.X0_Y180 :
(n && w ? ModelRotation.X0_Y270 : ModelRotation.X0_Y90)));
else if(sides == 2)
return provider.getModel(name)
return provider.getModel(pane)
.add(8, 0, 0, 8, 16, 16)
.w().uv(0, 0, 16, 16).noCull()
.e().uv(0, 0, 16, 16).noCull()
@ -293,7 +293,7 @@ public class BlockPane extends Block
.u().uv(9, 0, 7, 16).noCull()
.rotate(n ? ModelRotation.X0_Y0 : ModelRotation.X0_Y90);
else
return provider.getModel(name)
return provider.getModel(pane)
.add(8, 0, 0, 8, 16, 16)
.w().uv(0, 0, 16, 16).noCull()
.e().uv(0, 0, 16, 16).noCull()
@ -314,8 +314,6 @@ public class BlockPane extends Block
.rotate(!w ? ModelRotation.X0_Y0 : (!e ? ModelRotation.X0_Y180 : (!s ? ModelRotation.X0_Y270 : ModelRotation.X0_Y90)));
}
else {
String pane = this.getPaneBase(state);
String edge = this.getPaneEdge(state);
if(sides == 0 || sides == 4)
return provider.getModel(pane)
.add(7, 0, 0, 9, 16, 16).noShade()
@ -492,12 +490,12 @@ public class BlockPane extends Block
.e(edge).uv(7, 0, 9, 16);
}
}
protected Item getItemToRegister() {
return this.canDrop ? super.getItemToRegister() : new ItemBlock(this, "glass", false);
}
public Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, WEST, EAST};
}
public String getItemTexture(String name) {
return this.getPaneBase();
}
}

View file

@ -196,7 +196,7 @@ public class BlockPortal extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}
@ -239,11 +239,6 @@ public class BlockPortal extends Block
}
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
public int getRenderColor(State state)
{
return COLORS[state.getValue(DIM)];

View file

@ -76,7 +76,7 @@ public class BlockPortalFrame extends Block implements Rotatable
return Items.obsidian;
}
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 4;
}

View file

@ -8,7 +8,6 @@ import common.entity.types.EntityLiving;
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;
@ -24,6 +23,7 @@ public class BlockSkull extends Block implements Rotatable {
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
this.setFlatItemTexture();
}
public boolean canPlaceBlockAt(World world, BlockPos pos) {
@ -51,14 +51,6 @@ public class BlockSkull extends Block implements Rotatable {
return false;
}
public Item getItemDropped(State state, Random rand, int fortune) {
return Items.skull;
}
public Item getItem(World worldIn, BlockPos pos) {
return Items.skull;
}
public boolean isXrayVisible() {
return true;
}
@ -67,8 +59,4 @@ public class BlockSkull extends Block implements Rotatable {
world.destroyBlock(pos, true);
return true;
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Schädel").setTab(CheatTab.DECORATION);
}
}

View file

@ -57,10 +57,6 @@ public class BlockSlab extends Block implements Directional {
return new Property[] {FACING};
}
public boolean canSilkHarvest() {
return false;
}
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
State iblockstate = this.getState().withProperty(FACING, Facing.DOWN);
return facing != Facing.DOWN && (facing == Facing.UP || (double)hitY <= 0.5D) ? iblockstate : iblockstate.withProperty(FACING, Facing.UP);

View file

@ -7,7 +7,6 @@ import common.item.Item;
import common.item.block.ItemBlock;
import common.model.BlockLayer;
import common.properties.Property;
import common.world.State;
public class BlockStainedGlassPane extends BlockPane
{
@ -21,7 +20,7 @@ public class BlockStainedGlassPane extends BlockPane
public BlockStainedGlassPane(DyeColor color)
{
super(Material.TRANSLUCENT, false);
super(Material.TRANSLUCENT);
this.color = color;
this.setDefaultState(this.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
this.setTab(CheatTab.BLOCKS);
@ -42,15 +41,11 @@ public class BlockStainedGlassPane extends BlockPane
return new Property[] {NORTH, EAST, WEST, SOUTH};
}
protected String getPaneBase(State state) {
protected String getPaneBase() {
return this.color.getName() + "_glass";
}
protected String getPaneEdge(State state) {
protected String getPaneEdge() {
return this.color.getName() + "_glass_pane";
}
protected Item getItemToRegister() {
return new ItemBlock(this, "");
}
}

View file

@ -26,7 +26,7 @@ public class BlockBush extends Block
float f = 0.2F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
this.setTab(CheatTab.PLANTS);
this.setFlatItemTexture();
this.setFlatBlockTexture();
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)

View file

@ -11,11 +11,6 @@ import common.world.State;
public class BlockCarrot extends BlockCrops
{
protected Item getSeed()
{
return Items.carrot;
}
protected Item getCrop()
{
return Items.carrot;

View file

@ -2,12 +2,13 @@ package common.block.foliage;
import common.block.Block;
import common.block.Rotatable;
import common.color.DyeColor;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.item.material.ItemDye;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -116,7 +117,7 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable
/**
* 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)
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer)
{
Facing enumfacing = Facing.fromAngle((double)placer.rotYaw);
worldIn.setState(pos, state.withProperty(FACING, enumfacing), 2);
@ -168,15 +169,10 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable
for (int k = 0; k < j; ++k)
{
spawnAsEntity(worldIn, pos, new ItemStack(Items.cocoa));
spawnAsEntity(worldIn, pos, new ItemStack(this.getItem()));
}
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.cocoa;
}
/**
* Whether this IGrowable can grow
*/
@ -253,6 +249,6 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable
}
protected Item getItemToRegister() {
return null;
return new ItemDye(DyeColor.BROWN, this);
}
}

View file

@ -136,11 +136,6 @@ public class BlockCrops extends BlockBush implements IGrowable
return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock());
}
protected Item getSeed()
{
return Items.wheat;
}
protected Item getCrop()
{
return Items.wheats;
@ -165,7 +160,7 @@ public class BlockCrops extends BlockBush implements IGrowable
{
if (worldIn.rand.zrange(15) <= i)
{
spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed()));
spawnAsEntity(worldIn, pos, new ItemStack(this.getItem()));
}
}
}
@ -177,12 +172,7 @@ public class BlockCrops extends BlockBush implements IGrowable
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return ((Integer)state.getValue(AGE)).intValue() == 7 ? this.getCrop() : this.getSeed();
}
public Item getItem(World worldIn, BlockPos pos)
{
return this.getSeed();
return ((Integer)state.getValue(AGE)).intValue() == 7 ? this.getCrop() : super.getItemDropped(state, rand, fortune);
}
/**

View file

@ -46,6 +46,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
this.setHardness(0.0F);
this.setStepSound(SoundType.GRASS);
this.setFlammable(60, 100);
this.setFlatBlockTexture();
PLANTS[type.ordinal()] = this;
}
@ -149,7 +150,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
}
else
{
return this.type == BlockDoublePlant.EnumPlantType.FERN ? null : (this.type == BlockDoublePlant.EnumPlantType.GRASS ? (rand.chance(8) ? Items.wheat : null) : this.getItem());
return this.type == BlockDoublePlant.EnumPlantType.FERN ? null : (this.type == BlockDoublePlant.EnumPlantType.GRASS ? (rand.chance(8) ? Items.wheat : null) : super.getItemDropped(state, rand, fortune));
}
}
@ -167,7 +168,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
/**
* 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)
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer)
{
worldIn.setState(pos.up(), this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), 2);
}

View file

@ -25,7 +25,7 @@ public class BlockDryLeaves extends BlockLeavesBase
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return random.chance(0, 1, 5);
}

View file

@ -151,11 +151,6 @@ public class BlockFarmland extends Block
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune);
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.dirt;
}
protected Property[] getProperties()
{
return new Property[] {MOISTURE};

View file

@ -7,7 +7,6 @@ import common.color.Colorizer;
import common.init.Blocks;
import common.item.CheatTab;
import common.item.Item;
import common.item.block.ItemColored;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -31,6 +30,7 @@ public class BlockGrass extends Block implements IGrowable
this.setDefaultState(this.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
this.setTickRandomly();
this.setTab(CheatTab.NATURE);
this.setItemColored();
}
/**
@ -136,10 +136,6 @@ public class BlockGrass extends Block implements IGrowable
return provider.getModel("dirt").add().d().u("grass_top").tint().nswe("grass_side")
.add().nswe("grass_side_overlay").tint();
}
protected Item getItemToRegister() {
return new ItemColored(this);
}
public Property[] getUnsavedProperties() {
return new Property[] {SNOWY};

View file

@ -2,160 +2,107 @@ package common.block.foliage;
import common.block.Block;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.item.Item;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Identifyable;
import common.world.State;
import common.world.World;
public class BlockHugeMushroom extends Block
{
public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class);
private final Block smallBlock;
public class BlockHugeMushroom extends Block {
public static enum EnumType implements Identifyable {
NORTH_WEST("north_west"),
NORTH("north"),
NORTH_EAST("north_east"),
WEST("west"),
CENTER("center"),
EAST("east"),
SOUTH_WEST("south_west"),
SOUTH("south"),
SOUTH_EAST("south_east"),
STEM("stem"),
ALL_INSIDE("all_inside"),
ALL_OUTSIDE("all_outside"),
ALL_STEM("all_stem");
public BlockHugeMushroom(Material p_i46392_1_, Block p_i46392_3_)
{
super(p_i46392_1_);
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockHugeMushroom.EnumType.ALL_OUTSIDE));
this.smallBlock = p_i46392_3_;
}
private final String name;
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return Math.max(0, random.range(-7, 2));
}
private EnumType(String name) {
this.name = name;
}
// /**
// * Get the MapColor for this Block and the given BlockState
// */
// public MapColor getMapColor(IBlockState state)
// {
// switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT))
// {
// case ALL_STEM:
// return MapColor.clothColor;
//
// case ALL_INSIDE:
// return MapColor.sandColor;
//
// case STEM:
// return MapColor.sandColor;
//
// default:
// return super.getMapColor(state);
// }
// }
public String toString() {
return this.name;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return this.smallBlock.getItem();
}
public String getName() {
return this.name;
}
}
public Item getItem(World worldIn, BlockPos pos)
{
return this.smallBlock.getItem();
}
public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant",
BlockHugeMushroom.EnumType.class);
/**
* 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();
}
private final Block smallBlock;
protected Property[] getProperties()
{
return new Property[] {VARIANT};
}
public Model getModel(ModelProvider provider, String name, State state) {
switch(state.getValue(VARIANT)) {
case ALL_INSIDE:
return provider.getModel(name + "_inside").add().all();
case ALL_OUTSIDE:
default:
return provider.getModel(name + "_cap").add().all();
case ALL_STEM:
return provider.getModel(name + "_stem").add().all();
case STEM:
return provider.getModel(name + "_stem").add().nswe().du(name + "_inside");
case CENTER:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_inside")
.w(name + "_inside").e(name + "_inside");
case EAST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_inside")
.w(name + "_inside").e(name + "_cap");
case NORTH_EAST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_cap").s(name + "_inside")
.w(name + "_inside").e(name + "_cap");
case NORTH:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_cap").s(name + "_inside")
.w(name + "_inside").e(name + "_inside");
case NORTH_WEST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_cap").s(name + "_inside")
.w(name + "_cap").e(name + "_inside");
case SOUTH_EAST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_cap")
.w(name + "_inside").e(name + "_cap");
case SOUTH:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_cap")
.w(name + "_inside").e(name + "_inside");
case SOUTH_WEST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_cap")
.w(name + "_cap").e(name + "_inside");
case WEST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_inside")
.w(name + "_cap").e(name + "_inside");
}
}
public BlockHugeMushroom(Block smallBlock) {
super(Material.WOOD);
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockHugeMushroom.EnumType.ALL_OUTSIDE));
this.smallBlock = smallBlock;
}
public static enum EnumType implements Identifyable
{
NORTH_WEST("north_west"),
NORTH("north"),
NORTH_EAST("north_east"),
WEST("west"),
CENTER("center"),
EAST("east"),
SOUTH_WEST("south_west"),
SOUTH("south"),
SOUTH_EAST("south_east"),
STEM("stem"),
ALL_INSIDE("all_inside"),
ALL_OUTSIDE("all_outside"),
ALL_STEM("all_stem");
protected int quantityDropped(Random random) {
return Math.max(0, random.range(-7, 2));
}
private final String name;
public Item getItemDropped(State state, Random rand, int fortune) {
return this.smallBlock.getItemDropped(state, rand, fortune);
}
private EnumType(String name)
{
this.name = name;
}
protected Property[] getProperties() {
return new Property[] {VARIANT};
}
public String toString()
{
return this.name;
}
public String getName()
{
return this.name;
}
}
public Model getModel(ModelProvider provider, String name, State state) {
switch(state.getValue(VARIANT)) {
case ALL_INSIDE:
return provider.getModel(name + "_inside").add().all();
case ALL_OUTSIDE:
default:
return provider.getModel(name + "_cap").add().all();
case ALL_STEM:
return provider.getModel(name + "_stem").add().all();
case STEM:
return provider.getModel(name + "_stem").add().nswe().du(name + "_inside");
case CENTER:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_inside")
.w(name + "_inside").e(name + "_inside");
case EAST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_inside")
.w(name + "_inside").e(name + "_cap");
case NORTH_EAST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_cap").s(name + "_inside")
.w(name + "_inside").e(name + "_cap");
case NORTH:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_cap").s(name + "_inside")
.w(name + "_inside").e(name + "_inside");
case NORTH_WEST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_cap").s(name + "_inside")
.w(name + "_cap").e(name + "_inside");
case SOUTH_EAST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_cap")
.w(name + "_inside").e(name + "_cap");
case SOUTH:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_cap")
.w(name + "_inside").e(name + "_inside");
case SOUTH_WEST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_cap")
.w(name + "_cap").e(name + "_inside");
case WEST:
return provider.getModel(name + "_inside").add().d(name + "_inside").u(name + "_cap").n(name + "_inside").s(name + "_inside")
.w(name + "_cap").e(name + "_inside");
}
}
}

View file

@ -15,7 +15,6 @@ import common.init.WoodType;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemColored;
import common.item.tool.ItemShears;
import common.model.Model;
import common.model.ModelProvider;
@ -59,6 +58,7 @@ public class BlockLeaves extends BlockLeavesBase
this.setLightOpacity(1);
this.setStepSound(SoundType.GRASS);
this.setFlammable(30, 60);
this.setItemColored();
LEAVES.add(this);
MAPPING[type.ordinal() * LeavesType.values().length + subType.ordinal()] = this;
}
@ -224,7 +224,7 @@ public class BlockLeaves extends BlockLeavesBase
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return random.chance(0, 1, this.type.getSaplingChance());
}
@ -317,8 +317,4 @@ public class BlockLeaves extends BlockLeavesBase
public Property<?>[] getIgnoredProperties() {
return new Property[] {DECAY, BUSH};
}
protected Item getItemToRegister() {
return new ItemColored(this);
}
}

View file

@ -33,6 +33,8 @@ public class BlockLilyPad extends BlockBush implements Rotatable
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.PLANTS);
this.setFlatBlockTexture();
this.setItemColored();
}
public void addCollisionBoxesToList(World worldIn, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity)

View file

@ -29,7 +29,7 @@ public class BlockMelon extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return random.range(3, 7);
}
@ -37,7 +37,7 @@ public class BlockMelon extends Block
/**
* Get the quantity dropped based on the given fortune level
*/
public int quantityDroppedWithBonus(int fortune, Random random)
protected int quantityDroppedWithBonus(int fortune, Random random)
{
return Math.min(9, this.quantityDropped(random) + random.zrange(1 + fortune));
}

View file

@ -14,11 +14,6 @@ import common.world.World;
public class BlockPotato extends BlockCrops
{
protected Item getSeed()
{
return Items.potato;
}
protected Item getCrop()
{
return Items.potato;

View file

@ -7,7 +7,6 @@ import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.StackSize;
import common.item.block.ItemSmallBlock;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -34,6 +33,7 @@ public class BlockReed extends Block
float f = 0.375F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f);
this.setTickRandomly();
this.setFlatItemTexture();
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
@ -130,14 +130,6 @@ public class BlockReed extends Block
return null;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.reeds;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
@ -151,11 +143,6 @@ public class BlockReed extends Block
return false;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.reeds;
}
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
{
return worldIn.getBiomeGenForCoords(pos).getGrassColorAtPos(pos);
@ -180,6 +167,6 @@ public class BlockReed extends Block
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Zuckerrohr").setTab(CheatTab.PLANTS).setMaxAmount(StackSize.L);
return super.getItemToRegister().setMaxAmount(StackSize.L);
}
}

View file

@ -160,28 +160,18 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable
if (!worldIn.client)
{
Item item = this.getSeedItem();
int i = ((Integer)state.getValue(AGE)).intValue();
if (item != null)
for (int j = 0; j < 3; ++j)
{
int i = ((Integer)state.getValue(AGE)).intValue();
for (int j = 0; j < 3; ++j)
if (worldIn.rand.zrange(15) <= i)
{
if (worldIn.rand.zrange(15) <= i)
{
spawnAsEntity(worldIn, pos, new ItemStack(item));
}
spawnAsEntity(worldIn, pos, new ItemStack(this.getItem()));
}
}
}
}
protected Item getSeedItem()
{
return this.crop == Blocks.pumpkin ? Items.pumpkin_stem : (this.crop == Blocks.melon_block ? Items.melon_stem : null);
}
/**
* Get the Item that this Block should drop when harvested.
*/
@ -190,12 +180,6 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable
return null;
}
public Item getItem(World worldIn, BlockPos pos)
{
Item item = this.getSeedItem();
return item != null ? item : null;
}
/**
* Whether this IGrowable can grow
*/

View file

@ -7,7 +7,6 @@ import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemColored;
import common.item.tool.ItemShears;
import common.model.Model;
import common.model.ModelProvider;
@ -38,6 +37,8 @@ public class BlockTallGrass extends BlockBush implements IGrowable
float f = 0.4F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
this.setFlammable(60, 100);
this.setFlatBlockTexture();
this.setItemColored();
BUSHES[type.ordinal()] = this;
}
@ -97,7 +98,7 @@ public class BlockTallGrass extends BlockBush implements IGrowable
/**
* Get the quantity dropped based on the given fortune level
*/
public int quantityDroppedWithBonus(int fortune, Random random)
protected int quantityDroppedWithBonus(int fortune, Random random)
{
return random.roll(fortune * 2 + 1);
}
@ -146,12 +147,8 @@ public class BlockTallGrass extends BlockBush implements IGrowable
if(this.type != EnumType.DEAD_BUSH)
return provider.getModel(this.type.getName()).crossTint();
else
return provider.getModel("deadbush").cross();
return provider.getModel(this.type.getName()).cross();
}
protected Item getItemToRegister() {
return new ItemColored(this, "");
}
public static enum EnumType implements Identifyable
{

View file

@ -10,7 +10,6 @@ import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemColored;
import common.item.tool.ItemShears;
import common.model.BlockLayer;
import common.model.Model;
@ -45,6 +44,8 @@ public class BlockVine extends Block
this.setTickRandomly();
this.setTab(CheatTab.PLANTS);
this.setFlammable(15, 100);
this.setFlatBlockTexture();
this.setItemColored();
}
/**
@ -418,7 +419,7 @@ public class BlockVine extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}
@ -555,10 +556,6 @@ public class BlockVine extends Block
return model;
}
}
protected Item getItemToRegister() {
return new ItemColored(this, "");
}
public Property[] getUnsavedProperties() {
return new Property[] {UP};

View file

@ -83,7 +83,7 @@ public class BlockWart extends BlockBush
for (int j = 0; j < i; ++j)
{
spawnAsEntity(worldIn, pos, new ItemStack(Items.soul_wart));
spawnAsEntity(worldIn, pos, new ItemStack(this.getItem()));
}
}
}
@ -99,16 +99,11 @@ public class BlockWart extends BlockBush
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.soul_wart;
}
protected Property[] getProperties()
{
return new Property[] {AGE};

View file

@ -163,7 +163,7 @@ public abstract class BlockLiquid extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}

View file

@ -27,7 +27,7 @@ public class BlockClay extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 4;
}

View file

@ -96,7 +96,7 @@ public class BlockFire extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}

View file

@ -23,7 +23,7 @@ public class BlockGlowstone extends Block
/**
* Get the quantity dropped based on the given fortune level
*/
public int quantityDroppedWithBonus(int fortune, Random random)
protected int quantityDroppedWithBonus(int fortune, Random random)
{
return ExtMath.clampi(this.quantityDropped(random) + random.zrange(fortune + 1), 1, 4);
}
@ -31,7 +31,7 @@ public class BlockGlowstone extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return random.range(2, 4);
}

View file

@ -20,11 +20,11 @@ public class BlockGravel extends BlockFalling
{
int chance = Vars.flintChance;
if(chance <= 0)
return this.getItem();
return super.getItemDropped(state, rand, fortune);
fortune *= 3;
if(fortune >= chance)
fortune = chance - 1;
return rand.chance(chance - fortune) ? Items.flint : this.getItem();
return rand.chance(chance - fortune) ? Items.flint : super.getItemDropped(state, rand, fortune);
}
// public MapColor getMapColor(IBlockState state)

View file

@ -6,7 +6,6 @@ import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.item.CheatTab;
import common.item.ItemStack;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.util.BlockPos;
@ -26,24 +25,21 @@ public class BlockIce extends BlockTranslucent {
public void harvestBlock(World world, EntityNPC player, BlockPos pos, State state, TileEntity tile) {
if(this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player)) {
ItemStack stack = this.createStackedBlock(state);
if(stack != null)
spawnAsEntity(world, pos, stack);
super.harvestBlock(world, player, pos, state, tile);
}
else {
if(world.doesWaterVaporize(pos)) {
world.setBlockToAir(pos);
return;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
this.dropBlockAsItem(world, pos, state, fortune);
super.harvestBlock(world, player, pos, state, tile);
Material material = world.getState(pos.down()).getBlock().getMaterial();
if(material.blocksMovement() || material.isLiquid())
world.setState(pos, Blocks.flowing_water.getState());
}
}
public int quantityDropped(Random rand) {
protected int quantityDropped(Random rand) {
return 0;
}

View file

@ -48,7 +48,7 @@ public class BlockOre extends Block
public Item getItemDropped(State state, Random rand, int fortune)
{
return this.dropItem == null ? this.getItem() : this.dropItem.getItem();
return this.dropItem == null ? super.getItemDropped(state, rand, fortune) : this.dropItem.getItem();
// this == Blocks.coal_ore ? Items.coal :
// (this == Blocks.diamond_ore ? Items.diamond :
// (this == Blocks.lapis_ore ? Items.dye :
@ -57,13 +57,13 @@ public class BlockOre extends Block
// this.getItem()))));
}
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return this.dropItem == null ? 1 : (this.dropItem.getSize() + (this.dropChance > 0 ? random.zrange(this.dropChance + 1) : 0));
// this == Blocks.lapis_ore ? 4 + random.nextInt(5) : 1;
}
public int quantityDroppedWithBonus(int fortune, Random random)
protected int quantityDroppedWithBonus(int fortune, Random random)
{
if (fortune > 0 &&
this.getItem() != this.getItemDropped(this.getState(), random, fortune))

View file

@ -17,7 +17,7 @@ public class BlockPackedIce extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}

View file

@ -134,7 +134,7 @@ public class BlockSnow extends Block
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}

View file

@ -23,7 +23,7 @@ public class BlockSnowBlock extends Block {
return Items.snowball;
}
public int quantityDropped(Random rand) {
protected int quantityDropped(Random rand) {
return rand.range(2, 4);
}

View file

@ -21,7 +21,7 @@ public class BlockWeb extends Block
{
super(Material.FLUFF);
this.setTab(CheatTab.DECORATION);
this.setFlatItemTexture();
this.setFlatBlockTexture();
}
/**

View file

@ -19,7 +19,6 @@ public class BlockActiveDisplay extends BlockDisplay implements ITileEntityProvi
public BlockActiveDisplay(BlockInactiveDisplay inactive) {
super(inactive.getDensity());
this.hasTile = true;
this.setLightLevel(1.0f);
this.inactive = inactive;
inactive.setActive(this);
@ -27,9 +26,9 @@ public class BlockActiveDisplay extends BlockDisplay implements ITileEntityProvi
public void onBlockRemoved(AWorldServer world, BlockPos pos, State state) {
super.onBlockRemoved(world, pos, state);
world.removeTileEntity(pos);
Pair<BlockPos, BlockPos> span = removing ? null : this.getSpan(world, pos, state.getValue(FACING));
if(span != null) {
world.removeTileEntity(pos);
removing = true;
for(BlockPos loc : BlockPos.getAllInBox(span.first(), span.second())) {
if(!loc.equals(pos))
@ -39,12 +38,6 @@ public class BlockActiveDisplay extends BlockDisplay implements ITileEntityProvi
}
}
public boolean onBlockEventReceived(World world, BlockPos pos, State state, int id, int param) {
super.onBlockEventReceived(world, pos, state, id, param);
TileEntity tile = world.getTileEntity(pos);
return tile == null ? false : tile.receiveClientEvent(id, param);
}
public TileEntity createNewTileEntity() {
return new TileEntityDisplay(this.density);
}

View file

@ -208,7 +208,7 @@ public abstract class BlockBasePressurePlate extends Block
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canConnectToWire()
public boolean canConnectToWire(State state)
{
return true;
}

View file

@ -2,15 +2,12 @@ package common.block.tech;
import java.util.List;
import common.block.BlockContainer;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.inventory.InventoryHelper;
import common.item.CheatTab;
import common.item.Item;
import common.item.block.ItemSmallBlock;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
@ -28,7 +25,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockBrewingStand extends BlockContainer
public class BlockBrewingStand extends Block implements ITileEntityProvider
{
private static final Model brewing_stand_bottles_2 = ModelProvider.getModelProvider().getModel("brewing_stand")
.add(7, 0, 7, 9, 14, 9)
@ -356,6 +353,7 @@ public class BlockBrewingStand extends BlockContainer
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(HAS_BOTTLE[0], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[1], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[2], Boolean.valueOf(false)));
this.setFlatItemTexture();
}
// /**
@ -374,14 +372,6 @@ public class BlockBrewingStand extends BlockContainer
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
@ -454,19 +444,6 @@ public class BlockBrewingStand extends BlockContainer
super.onBlockRemoved(worldIn, pos, state);
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.brewing_stand;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.brewing_stand;
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
@ -485,8 +462,4 @@ public class BlockBrewingStand extends BlockContainer
return brewing_stand_bottles[(state.getValue(HAS_BOTTLE[0]) ? 1 : 0) | (state.getValue(HAS_BOTTLE[1]) ? 2 : 0)
| (state.getValue(HAS_BOTTLE[2]) ? 4 : 0)];
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Braustand").setTab(CheatTab.TECHNOLOGY);
}
}

View file

@ -214,7 +214,7 @@ public class BlockButton extends Block implements Directional
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canConnectToWire()
public boolean canConnectToWire(State state)
{
return true;
}

View file

@ -11,7 +11,6 @@ import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemSmallBlock;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.Property;
@ -413,6 +412,7 @@ public class BlockCauldron extends Block
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(LEVEL, Integer.valueOf(0)));
this.setFlatItemTexture();
}
/**
@ -571,19 +571,6 @@ public class BlockCauldron extends Block
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.cauldron;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.cauldron;
}
protected Property[] getProperties()
{
return new Property[] {LEVEL};
@ -596,8 +583,4 @@ public class BlockCauldron extends Block
public Model getModel(ModelProvider provider, String name, State state) {
return cauldron_levels[state.getValue(LEVEL)];
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Kessel").setTab(CheatTab.TECHNOLOGY);
}
}

View file

@ -2,7 +2,8 @@ package common.block.tech;
import java.util.Map;
import common.block.BlockContainer;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.block.Rotatable;
import common.block.SoundType;
import common.collect.Maps;
@ -12,13 +13,12 @@ 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.IInventory;
import common.inventory.InventoryHelper;
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;
@ -32,7 +32,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockChest extends BlockContainer implements Rotatable
public class BlockChest extends Block implements ITileEntityProvider, Rotatable
{
private static final Map<Integer, BlockChest> CHESTS = Maps.newHashMap();
@ -84,19 +84,6 @@ public class BlockChest extends BlockContainer implements Rotatable
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setCustomName(stack.getDisplayName());
}
}
}
public State correctFacing(World worldIn, BlockPos pos, State state)
{
Facing enumfacing = null;
@ -173,8 +160,8 @@ public class BlockChest extends BlockContainer implements Rotatable
if (chest != null)
{
ItemStack stack = Vars.locking ? playerIn.getHeldItem() : null;
if(stack != null && stack.getItem() instanceof ItemKey) {
ItemStack stack = playerIn.getHeldItem();
if(Vars.locking && stack != null && stack.getItem() instanceof ItemKey) {
if(chest.getLockCode() != null) {
if(stack.hasDisplayName() && stack.getDisplayName().equals(chest.getLockCode())) {
chest.setLockCode(null);
@ -189,7 +176,11 @@ public class BlockChest extends BlockContainer implements Rotatable
playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
return true;
}
}
}
else if(stack != null && stack.getItem() == Items.name_tag && stack.hasDisplayName()) {
chest.setCustomName(stack.getDisplayName());
return true;
}
playerIn.connection.show(chest);
}
@ -250,8 +241,4 @@ public class BlockChest extends BlockContainer implements Rotatable
public String getFallbackTexture() {
return "oak_planks";
}
protected Item getItemToRegister() {
return new ItemChest(this);
}
}

View file

@ -1,6 +1,7 @@
package common.block.tech;
import common.block.BlockContainer;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.block.SoundType;
import common.entity.npc.EntityNPC;
@ -13,7 +14,6 @@ import common.model.ModelProvider;
import common.model.Transforms;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDaylightDetector;
import common.util.BlockPos;
@ -25,7 +25,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockDaylightDetector extends BlockContainer
public class BlockDaylightDetector extends Block implements ITileEntityProvider
{
public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
private final boolean inverted;
@ -105,15 +105,7 @@ public class BlockDaylightDetector extends BlockContainer
// }
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.daylight_detector;
}
public Item getItem(World worldIn, BlockPos pos)
public Item getItem()
{
return Items.daylight_detector;
}
@ -131,18 +123,10 @@ public class BlockDaylightDetector extends BlockContainer
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canConnectToWire()
public boolean canConnectToWire(State state)
{
return true;
}

View file

@ -1,7 +1,8 @@
package common.block.tech;
import common.block.BlockContainer;
import common.block.Block;
import common.block.Directional;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.item.EntityItem;
import common.entity.npc.EntityNPC;
@ -23,7 +24,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockDispenser extends BlockContainer implements Directional
public class BlockDispenser extends Block implements ITileEntityProvider, Directional
{
protected Random rand = new Random();
@ -158,14 +159,6 @@ public class BlockDispenser extends BlockContainer implements Directional
return new Vec3(d0, d1, d2);
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
*/

View file

@ -1,7 +1,7 @@
package common.block.tech;
import common.block.Block;
import common.block.BlockContainer;
import common.block.ITileEntityProvider;
import common.block.Rotatable;
import common.block.Material;
import common.entity.npc.EntityNPC;
@ -25,7 +25,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockFurnace extends BlockContainer implements Rotatable
public class BlockFurnace extends Block implements ITileEntityProvider, Rotatable
{
private final boolean isBurning;
private static boolean keepInventory;
@ -37,14 +37,6 @@ public class BlockFurnace extends BlockContainer implements Rotatable
this.isBurning = isBurning;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.furnace;
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
this.setDefaultFacing(worldIn, pos, state);
@ -195,19 +187,11 @@ public class BlockFurnace extends BlockContainer implements Rotatable
super.onBlockRemoved(worldIn, pos, state);
}
public Item getItem(World worldIn, BlockPos pos)
public Item getItem()
{
return Items.furnace;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
*/
@ -225,4 +209,8 @@ public class BlockFurnace extends BlockContainer implements Rotatable
return provider.getModel("furnace_side").add().du("furnace_top").n("furnace_front_" + (this.isBurning ? "on" : "off"))
.s().we().rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
protected Item getItemToRegister() {
return this.isBurning ? null : super.getItemToRegister();
}
}

View file

@ -1,8 +1,10 @@
package common.block.tech;
import java.util.List;
import common.block.BlockContainer;
import common.block.Block;
import common.block.DirectionalDown;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -26,7 +28,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockHopper extends BlockContainer implements DirectionalDown
public class BlockHopper extends Block implements ITileEntityProvider, DirectionalDown
{
private static final Model hopper_down = ModelProvider.getModelProvider().getModel("hopper_outside")
.add(0, 10, 0, 16, 11, 16)
@ -86,6 +88,7 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
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);
this.setFlatItemTexture();
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
@ -168,14 +171,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
super.onBlockRemoved(worldIn, pos, state);
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
public boolean isFullCube()
{
return false;
@ -261,8 +256,4 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
.e().uv(0, 8, 4, 12).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
protected Item getItemToRegister() {
return new ItemBlock(this, "hopper", true);
}
}

View file

@ -41,10 +41,6 @@ public class BlockInactiveDisplay extends BlockDisplay {
}
return true;
}
protected Item getItemToRegister() {
return new ItemBlock(this, BlockRegistry.getName(this));
}
protected BlockDisplay getOtherBlock() {
return this.active;

View file

@ -34,6 +34,7 @@ public class BlockLever extends Block
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, BlockLever.EnumOrientation.NORTH).withProperty(POWERED, Boolean.valueOf(false)));
this.setTab(CheatTab.TECHNOLOGY);
this.setFlatBlockTexture();
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
@ -238,7 +239,7 @@ public class BlockLever extends Block
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canConnectToWire()
public boolean canConnectToWire(State state)
{
return true;
}
@ -288,10 +289,6 @@ public class BlockLever extends Block
.e("lever").uv(7, 6, 9, 16).noCull()
.rotate(getRotation(state.getValue(FACING)));
}
protected Item getItemToRegister() {
return new ItemBlock(this, "lever", false);
}
public static enum EnumOrientation implements Identifyable, DirectionVec<EnumOrientation>
{

View file

@ -111,15 +111,7 @@ public class BlockLitTorch extends BlockTorch {
return null;
}
public Item getItemDropped(State state, Random rand, int fortune) {
public Item getItem() {
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

@ -20,7 +20,6 @@ import common.world.AWorldServer;
public abstract class BlockMachine extends Block implements Rotatable, ITileEntityProvider {
protected BlockMachine(Material material) {
super(material);
this.hasTile = true;
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.TECHNOLOGY);
}
@ -58,13 +57,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
InventoryHelper.dropInventoryItems(worldIn, pos, (Device)tileentity);
}
super.onBlockRemoved(worldIn, pos, state);
worldIn.removeTileEntity(pos);
}
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);
}
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {

View file

@ -57,6 +57,6 @@ public class BlockNuke extends Block
}
protected Item getItemToRegister() {
return new ItemBlock(this).setColor(TextColor.RED);
return super.getItemToRegister().setColor(TextColor.RED);
}
}

View file

@ -14,15 +14,12 @@ import common.init.Blocks;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemPiston;
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.TileEntityPiston;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
@ -249,6 +246,7 @@ public class BlockPistonBase extends Block implements Directional
}
public static final PropertyBool EXTENDED = PropertyBool.create("extended");
private static final List<Entity> TEMP_ENTITIES = Lists.<Entity>newArrayList();
/** This piston is the sticky one? */
private final boolean isSticky;
@ -274,7 +272,7 @@ public class BlockPistonBase extends Block implements Directional
/**
* 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)
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer)
{
worldIn.setState(pos, state.withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)), 2);
@ -321,13 +319,34 @@ public class BlockPistonBase extends Block implements Directional
{
if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
{
worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
if (!this.doMove(worldIn, pos, enumfacing, true))
{
return;
}
worldIn.setState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
worldIn.playSound(SoundEvent.PISTON_OUT, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.5F);
}
}
else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
{
worldIn.setState(pos, state.withProperty(EXTENDED, Boolean.valueOf(false)), 2);
worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
if (this.isSticky)
{
BlockPos blockpos = pos.add(enumfacing.getFrontOffsetX() * 2, enumfacing.getFrontOffsetY() * 2, enumfacing.getFrontOffsetZ() * 2);
Block block = worldIn.getState(blockpos).getBlock();
if (block != Blocks.air && canPush(block, worldIn, blockpos, enumfacing.getOpposite(), false) && (block.getMobilityFlag() == 0 || block == Blocks.piston || block == Blocks.sticky_piston))
{
this.doMove(worldIn, pos, enumfacing, false);
}
}
else
{
worldIn.setBlockToAir(pos.offset(enumfacing));
}
worldIn.playSound(SoundEvent.PISTON_IN, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.5F);
}
}
@ -361,89 +380,6 @@ public class BlockPistonBase extends Block implements Directional
// }
}
/**
* Called on both Client and Server when World#addBlockEvent is called
*/
public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam)
{
Facing enumfacing = (Facing)state.getValue(FACING);
if (!worldIn.client)
{
boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);
if (flag && eventID == 1)
{
worldIn.setState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
return false;
}
if (!flag && eventID == 0)
{
return false;
}
}
if (eventID == 0)
{
if (!this.doMove(worldIn, pos, enumfacing, true))
{
return false;
}
worldIn.setState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
worldIn.playSound(SoundEvent.PISTON_OUT, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.5F);
}
else if (eventID == 1)
{
TileEntity tileentity1 = worldIn.getTileEntity(pos.offset(enumfacing));
if (tileentity1 instanceof TileEntityPiston)
{
((TileEntityPiston)tileentity1).clearPistonTileEntity();
}
worldIn.setState(pos, Blocks.piston_extension.getState().withProperty(BlockPistonMoving.FACING, enumfacing).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT), 3);
worldIn.setTileEntity(pos, BlockPistonMoving.newTileEntity(this.getState().withProperty(FACING, getFacing(eventParam)).withProperty(EXTENDED, (eventParam & 8) > 0), enumfacing, false, true));
if (this.isSticky)
{
BlockPos blockpos = pos.add(enumfacing.getFrontOffsetX() * 2, enumfacing.getFrontOffsetY() * 2, enumfacing.getFrontOffsetZ() * 2);
Block block = worldIn.getState(blockpos).getBlock();
boolean flag1 = false;
if (block == Blocks.piston_extension)
{
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if (tileentity instanceof TileEntityPiston)
{
TileEntityPiston tileentitypiston = (TileEntityPiston)tileentity;
if (tileentitypiston.getFacing() == enumfacing && tileentitypiston.isExtending())
{
tileentitypiston.clearPistonTileEntity();
flag1 = true;
}
}
}
if (!flag1 && block != Blocks.air && canPush(block, worldIn, blockpos, enumfacing.getOpposite(), false) && (block.getMobilityFlag() == 0 || block == Blocks.piston || block == Blocks.sticky_piston))
{
this.doMove(worldIn, pos, enumfacing, false);
}
}
else
{
worldIn.setBlockToAir(pos.offset(enumfacing));
}
worldIn.playSound(SoundEvent.PISTON_IN, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.5F);
}
return true;
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
State iblockstate = worldIn.getState(pos);
@ -634,8 +570,7 @@ public class BlockPistonBase extends Block implements Directional
Block block1 = iblockstate.getBlock();
worldIn.setBlockToAir(blockpos2);
blockpos2 = blockpos2.offset(enumfacing);
worldIn.setState(blockpos2, Blocks.piston_extension.getState().withProperty(FACING, direction), 4);
worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
worldIn.setState(blockpos2, iblockstate, 2);
--i;
ablock[i] = block1;
}
@ -644,11 +579,8 @@ public class BlockPistonBase extends Block implements Directional
if (extending)
{
BlockPistonHead.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT;
State iblockstate1 = Blocks.piston_head.getState().withProperty(BlockPistonHead.FACING, direction).withProperty(BlockPistonHead.TYPE, blockpistonextension$enumpistontype);
State iblockstate2 = Blocks.piston_extension.getState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT);
worldIn.setState(blockpos1, iblockstate2, 4);
worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
State iblockstate1 = (this.isSticky ? Blocks.sticky_piston_head : Blocks.piston_head).getState().withProperty(BlockPistonHead.FACING, direction);
worldIn.setState(blockpos1, iblockstate1, 2);
}
for (int l = list1.size() - 1; l >= 0; --l)
@ -663,7 +595,7 @@ public class BlockPistonBase extends Block implements Directional
if (extending)
{
worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
worldIn.notifyNeighborsOfStateChange(blockpos1, this.isSticky ? Blocks.sticky_piston_head : Blocks.piston_head);
worldIn.notifyNeighborsOfStateChange(pos, this);
}
@ -671,6 +603,50 @@ public class BlockPistonBase extends Block implements Directional
}
}
private void launchWithSlimeBlock(World world, BlockPos pos, Facing pistonFacing, boolean extending)
{
float step = 0.25f;
State state = world.getState(pos);
BoundingBox axisalignedbb = state.getBlock().getCollisionBoundingBox(world, pos, state);
if (axisalignedbb != null)
{
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb);
if (!list.isEmpty())
{
TEMP_ENTITIES.addAll(list);
for (Entity entity : TEMP_ENTITIES)
{
if (state.getBlock() == Blocks.slime_block && extending)
{
switch (pistonFacing.getAxis())
{
case X:
entity.motionX = (double)pistonFacing.getFrontOffsetX();
break;
case Y:
entity.motionY = (double)pistonFacing.getFrontOffsetY();
break;
case Z:
entity.motionZ = (double)pistonFacing.getFrontOffsetZ();
}
}
else
{
entity.moveEntity((double)pistonFacing.getFrontOffsetX(), (double)pistonFacing.getFrontOffsetY(), (double)pistonFacing.getFrontOffsetZ());
}
}
TEMP_ENTITIES.clear();
}
}
}
/**
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
*/

View file

@ -14,13 +14,10 @@ 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.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.Identifyable;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
@ -28,38 +25,17 @@ import common.world.AWorldServer;
public class BlockPistonHead extends Block implements Directional
{
public static final PropertyEnum<BlockPistonHead.EnumPistonType> TYPE = PropertyEnum.<BlockPistonHead.EnumPistonType>create("type", BlockPistonHead.EnumPistonType.class);
public static final PropertyBool SHORT = PropertyBool.create("short");
private final boolean sticky;
public BlockPistonHead()
public BlockPistonHead(boolean sticky)
{
super(Material.PISTON);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(TYPE, BlockPistonHead.EnumPistonType.DEFAULT).withProperty(SHORT, Boolean.valueOf(false)));
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setStepSound(SoundType.STONE);
this.setHardness(0.5F);
this.sticky = sticky;
}
// public void onBlockHarvested(World worldIn, BlockPos pos, State state, EntityNPC player)
// {
// if (player.creative)
// {
// Facing enumfacing = (Facing)state.getValue(FACING);
//
// if (enumfacing != null)
// {
// BlockPos blockpos = pos.offset(enumfacing.getOpposite());
// Block block = worldIn.getState(blockpos).getBlock();
//
// if (block == Blocks.piston || block == Blocks.sticky_piston)
// {
// worldIn.setBlockToAir(blockpos);
// }
// }
// }
//
// super.onBlockHarvested(worldIn, pos, state, player);
// }
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockRemoved(worldIn, pos, state);
@ -103,7 +79,7 @@ public class BlockPistonHead extends Block implements Directional
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 0;
}
@ -219,38 +195,19 @@ public class BlockPistonHead extends Block implements Directional
return true;
}
public static Facing getFacing(int meta)
public Item getItem()
{
int i = meta & 7;
return i > 5 ? Facing.getFront(0) : Facing.getFront(i);
}
public Item getItem(World worldIn, BlockPos pos)
{
return worldIn.getState(pos).getValue(TYPE) == BlockPistonHead.EnumPistonType.STICKY ? Items.sticky_piston : Items.piston;
return this.sticky ? Items.sticky_piston : Items.piston;
}
protected Property[] getProperties()
{
return new Property[] {FACING, TYPE, SHORT};
return new Property[] {FACING};
}
public Model getModel(ModelProvider provider, String name, State state) {
String side = "piston_side";
return (state.getValue(SHORT) ? provider.getModel(state.getValue(TYPE) == EnumPistonType.STICKY ? "piston_top_sticky" : "piston_top")
.add(0, 0, 0, 16, 16, 4)
.d(side).uv(0, 0, 16, 4).rot(180)
.u(side).uv(0, 0, 16, 4)
.n().uv(0, 0, 16, 16)
.s("piston_top").uv(0, 0, 16, 16).noCull()
.w(side).uv(0, 0, 16, 4).rot(270)
.e(side).uv(0, 0, 16, 4).rot(90)
.add(6, 6, 4, 10, 10, 16)
.d(side).uv(4, 0, 16, 4).rot(90).noCull()
.u(side).uv(4, 0, 16, 4).rot(270).noCull()
.w(side).uv(16, 4, 4, 0).noCull()
.e(side).uv(4, 0, 16, 4).noCull()
: provider.getModel(state.getValue(TYPE) == EnumPistonType.STICKY ? "piston_top_sticky" : "piston_top")
return provider.getModel(this.sticky ? "piston_top_sticky" : "piston_top")
.add(0, 0, 0, 16, 16, 4)
.d(side).uv(0, 0, 16, 4).rot(180)
.u(side).uv(0, 0, 16, 4)
@ -267,7 +224,7 @@ public class BlockPistonHead extends Block implements Directional
.d(side).uv(0, 0, 4, 4).rot(90).noCull()
.u(side).uv(0, 0, 4, 4).rot(270).noCull()
.w(side).uv(4, 4, 0, 0).noCull()
.e(side).uv(0, 0, 4, 4).noCull())
.e(side).uv(0, 0, 4, 4).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING).getAxis() == Facing.Axis.Y
? state.getValue(FACING).getOpposite() : state.getValue(FACING)));
}
@ -275,31 +232,4 @@ public class BlockPistonHead extends Block implements Directional
protected Item getItemToRegister() {
return null;
}
public Property[] getUnsavedProperties() {
return new Property[] {SHORT};
}
public static enum EnumPistonType implements Identifyable
{
DEFAULT("normal"),
STICKY("sticky");
private final String name;
private EnumPistonType(String name)
{
this.name = name;
}
public String toString()
{
return this.name;
}
public String getName()
{
return this.name;
}
}
}

View file

@ -1,293 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.BlockContainer;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.item.Item;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityPiston;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.HitPosition;
import common.util.Vec3;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockPistonMoving extends BlockContainer
{
public static final PropertyEnum<Facing> FACING = BlockPistonHead.FACING;
public static final PropertyEnum<BlockPistonHead.EnumPistonType> TYPE = BlockPistonHead.TYPE;
public BlockPistonMoving()
{
super(Material.PISTON);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(TYPE, BlockPistonHead.EnumPistonType.DEFAULT));
this.setHardness(-1.0F);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return null;
}
public static TileEntity newTileEntity(State state, Facing facing, boolean extending, boolean renderHead)
{
return new TileEntityPiston(state, facing, extending, renderHead);
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityPiston)
{
((TileEntityPiston)tileentity).clearPistonTileEntity();
}
else
{
super.onBlockRemoved(worldIn, pos, state);
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return false;
}
/**
* Check whether this Block can be placed on the given side
*/
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, Facing side)
{
return false;
}
/**
* Called when a player destroys this Block
*/
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, State state)
{
BlockPos blockpos = pos.offset(((Facing)state.getValue(FACING)).getOpposite());
State iblockstate = worldIn.getState(blockpos);
if (iblockstate.getBlock() instanceof BlockPistonBase && ((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue())
{
worldIn.setBlockToAir(blockpos);
}
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if (!worldIn.client && worldIn.getTileEntity(pos) == null)
{
worldIn.setBlockToAir(pos);
return true;
}
else
{
return false;
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return null;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, State state, float chance, int fortune)
{
if (!worldIn.client)
{
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
if (tileentitypiston != null)
{
State iblockstate = tileentitypiston.getPistonState();
iblockstate.getBlock().dropBlockAsItem(worldIn, pos, iblockstate, 0);
}
}
}
/**
* 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)
{
return null;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
worldIn.getTileEntity(pos);
}
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
{
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
if (tileentitypiston == null)
{
return null;
}
else
{
float f = tileentitypiston.getProgress(0.0F);
if (tileentitypiston.isExtending())
{
f = 1.0F - f;
}
return this.getBoundingBox(worldIn, pos, tileentitypiston.getPistonState(), f, tileentitypiston.getFacing());
}
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
if (tileentitypiston != null)
{
State iblockstate = tileentitypiston.getPistonState();
Block block = iblockstate.getBlock();
if (block == this || block == Blocks.air)
{
return;
}
float f = tileentitypiston.getProgress(0.0F);
if (tileentitypiston.isExtending())
{
f = 1.0F - f;
}
block.setBlockBoundsBasedOnState(worldIn, pos);
if (block == Blocks.piston || block == Blocks.sticky_piston)
{
f = 0.0F;
}
Facing enumfacing = tileentitypiston.getFacing();
this.minX = block.getBlockBoundsMinX() - (double)((float)enumfacing.getFrontOffsetX() * f);
this.minY = block.getBlockBoundsMinY() - (double)((float)enumfacing.getFrontOffsetY() * f);
this.minZ = block.getBlockBoundsMinZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
this.maxX = block.getBlockBoundsMaxX() - (double)((float)enumfacing.getFrontOffsetX() * f);
this.maxY = block.getBlockBoundsMaxY() - (double)((float)enumfacing.getFrontOffsetY() * f);
this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
}
}
public BoundingBox getBoundingBox(World worldIn, BlockPos pos, State extendingBlock, float progress, Facing direction)
{
if (extendingBlock.getBlock() != this && extendingBlock.getBlock() != Blocks.air)
{
BoundingBox axisalignedbb = extendingBlock.getBlock().getCollisionBoundingBox(worldIn, pos, extendingBlock);
if (axisalignedbb == null)
{
return null;
}
else
{
double d0 = axisalignedbb.minX;
double d1 = axisalignedbb.minY;
double d2 = axisalignedbb.minZ;
double d3 = axisalignedbb.maxX;
double d4 = axisalignedbb.maxY;
double d5 = axisalignedbb.maxZ;
if (direction.getFrontOffsetX() < 0)
{
d0 -= (double)((float)direction.getFrontOffsetX() * progress);
}
else
{
d3 -= (double)((float)direction.getFrontOffsetX() * progress);
}
if (direction.getFrontOffsetY() < 0)
{
d1 -= (double)((float)direction.getFrontOffsetY() * progress);
}
else
{
d4 -= (double)((float)direction.getFrontOffsetY() * progress);
}
if (direction.getFrontOffsetZ() < 0)
{
d2 -= (double)((float)direction.getFrontOffsetZ() * progress);
}
else
{
d5 -= (double)((float)direction.getFrontOffsetZ() * progress);
}
return new BoundingBox(d0, d1, d2, d3, d4, d5);
}
}
else
{
return null;
}
}
private TileEntityPiston getTileEntity(IWorldAccess worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity instanceof TileEntityPiston ? (TileEntityPiston)tileentity : null;
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
protected Property[] getProperties()
{
return new Property[] {FACING, TYPE};
}
protected Item getItemToRegister() {
return null;
}
}

View file

@ -45,7 +45,7 @@ public class BlockRail extends Block
super(Material.SMALL);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
this.setTab(CheatTab.TECHNOLOGY);
this.setFlatItemTexture();
this.setFlatBlockTexture();
this.setDefaultState(this.getBaseState().withProperty(SHAPE, BlockRail.EnumRailDirection.NORTH_SOUTH));
}

View file

@ -44,18 +44,10 @@ public class BlockToggleableLight extends Block {
return true;
}
public Item getItemDropped(State state, Random rand, int fortune) {
public Item getItem() {
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;
}

View file

@ -37,7 +37,7 @@ public abstract class BlockTorch extends Block implements DirectionalUp
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.UP));
this.setTab(CheatTab.TECHNOLOGY);
this.setFlatItemTexture();
this.setFlatBlockTexture();
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)

View file

@ -11,7 +11,6 @@ import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.StackSize;
import common.item.block.ItemSmallBlock;
import common.item.tool.ItemShears;
import common.model.BlockLayer;
import common.model.Model;
@ -46,6 +45,7 @@ public class BlockTripWire extends Block
this.setDefaultState(this.getBaseState().withProperty(POWERED, Boolean.valueOf(false)).withProperty(SUSPENDED, Boolean.valueOf(false)).withProperty(ATTACHED, Boolean.valueOf(false)).withProperty(DISARMED, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.15625F, 1.0F);
// this.setTickRandomly(true);
this.setFlatItemTexture();
}
/**
@ -80,19 +80,6 @@ public class BlockTripWire extends Block
return BlockLayer.TRANSLUCENT;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.string;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.string;
}
/**
* Called when a neighboring block changes.
*/
@ -663,7 +650,7 @@ public class BlockTripWire extends Block
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Faden").setTab(CheatTab.TECHNOLOGY).setMaxAmount(StackSize.XXXL);
return super.getItemToRegister().setMaxAmount(StackSize.XXXL);
}
public Property[] getUnsavedProperties() {

View file

@ -8,7 +8,6 @@ import common.init.Blocks;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemBlock;
import common.model.BlockLayer;
import common.model.Model;
@ -37,6 +36,7 @@ public class BlockTripWireHook extends Block implements Rotatable
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(POWERED, Boolean.valueOf(false)).withProperty(ATTACHED, Boolean.valueOf(false)).withProperty(SUSPENDED, Boolean.valueOf(false)));
this.setTab(CheatTab.TECHNOLOGY);
// this.setTickRandomly(true);
this.setFlatBlockTexture();
}
/**
@ -106,7 +106,7 @@ public class BlockTripWireHook extends Block implements Rotatable
/**
* 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)
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer)
{
this.triggerHookAt(worldIn, pos, state, false, false, -1, (State)null);
}
@ -326,7 +326,7 @@ public class BlockTripWireHook extends Block implements Rotatable
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canConnectToWire()
public boolean canConnectToWire(State state)
{
return true;
}
@ -555,10 +555,6 @@ public class BlockTripWireHook extends Block implements Rotatable
}
return model.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
protected Item getItemToRegister() {
return new ItemBlock(this, "tripwire_hook", false);
}
public Property[] getUnsavedProperties() {
return new Property[] {SUSPENDED};

View file

@ -11,7 +11,6 @@ import common.inventory.ContainerChest;
import common.inventory.InventoryPlayer;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
@ -71,7 +70,7 @@ public class BlockWarpChest extends Block implements Rotatable
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
protected int quantityDropped(Random random)
{
return 8;
}
@ -90,14 +89,6 @@ public class BlockWarpChest extends Block implements Rotatable
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)
{
worldIn.setState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if(!worldIn.client) {

View file

@ -1,29 +1,24 @@
package common.block.tech;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import common.block.Block;
import common.block.Material;
import common.collect.Lists;
import common.collect.Sets;
import common.init.Blocks;
import common.item.Item;
import common.item.block.ItemWire;
import common.item.StackSize;
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.properties.PropertyInteger;
import common.properties.PropertyBool;
import common.rng.Random;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.Identifyable;
import common.world.IBlockAccess;
import common.world.IWorldAccess;
import common.world.State;
@ -240,49 +235,36 @@ public class BlockWire extends Block
.w("wire_line").uv(0, 0, 16, 16).rot(90).noCull()
.rotate(rot);
}
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 final Set<BlockPos> blocksNeedingUpdate = Sets.<BlockPos>newHashSet();
public static final PropertyBool DOWN = PropertyBool.create("down");
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west");
public BlockWire()
{
super(Material.SMALL);
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.setDefaultState(this.getBaseState().withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
this.setFlatItemTexture();
}
/**
* 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)
{
state = state.withProperty(WEST, this.getAttachPosition(worldIn, pos, Facing.WEST));
state = state.withProperty(EAST, this.getAttachPosition(worldIn, pos, Facing.EAST));
state = state.withProperty(NORTH, this.getAttachPosition(worldIn, pos, Facing.NORTH));
state = state.withProperty(SOUTH, this.getAttachPosition(worldIn, pos, Facing.SOUTH));
state = state.withProperty(DOWN, this.canConnect(worldIn, pos, Facing.DOWN));
state = state.withProperty(UP, this.canConnect(worldIn, pos, Facing.UP));
state = state.withProperty(WEST, this.canConnect(worldIn, pos, Facing.WEST));
state = state.withProperty(EAST, this.canConnect(worldIn, pos, Facing.EAST));
state = state.withProperty(NORTH, this.canConnect(worldIn, pos, Facing.NORTH));
state = state.withProperty(SOUTH, this.canConnect(worldIn, pos, Facing.SOUTH));
return state;
}
private EnumAttachPosition getAttachPosition(IBlockAccess worldIn, BlockPos pos, Facing direction)
private boolean canConnect(IBlockAccess worldIn, BlockPos pos, Facing direction)
{
BlockPos blockpos = pos.offset(direction);
Block block = worldIn.getState(pos.offset(direction)).getBlock();
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() && this.canConnectUpwardsTo(worldIn.getState(blockpos.up())) ? EnumAttachPosition.UP : EnumAttachPosition.NONE;
}
else
{
return EnumAttachPosition.SIDE;
}
return worldIn.getState(pos.offset(direction)).getBlock().canConnectToWire(this.getState());
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
@ -290,9 +272,6 @@ public class BlockWire extends Block
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
@ -302,265 +281,6 @@ public class BlockWire extends Block
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.isBlockSolid(pos.down()) || worldIn.getState(pos.down()).getBlock() == Blocks.glowstone;
}
private State updateSurroundings(World worldIn, BlockPos pos, State state)
{
state = this.calculateCurrentChanges(worldIn, pos, pos, state);
List<BlockPos> list = Lists.newArrayList(this.blocksNeedingUpdate);
this.blocksNeedingUpdate.clear();
for (BlockPos blockpos : list)
{
worldIn.notifyNeighborsOfStateChange(blockpos, this);
}
return state;
}
private State calculateCurrentChanges(World worldIn, BlockPos pos1, BlockPos pos2, State state)
{
State iblockstate = state;
int i = ((Integer)state.getValue(POWER)).intValue();
int j = 0;
j = this.getMaxCurrentStrength(worldIn, pos2, j);
// this.canProvidePower = false;
int k = 0; // TODO: worldIn.isBlockIndirectlyGettingPowered(pos1);
// this.canProvidePower = true;
if (k > 0 && k > j - 1)
{
j = k;
}
int l = 0;
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos1.offset(enumfacing);
boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();
if (flag)
{
l = this.getMaxCurrentStrength(worldIn, blockpos, l);
}
if (worldIn.getState(blockpos).getBlock().isNormalCube() && !worldIn.getState(pos1.up()).getBlock().isNormalCube())
{
if (flag && pos1.getY() >= pos2.getY())
{
l = this.getMaxCurrentStrength(worldIn, blockpos.up(), l);
}
}
else if (!worldIn.getState(blockpos).getBlock().isNormalCube() && flag && pos1.getY() <= pos2.getY())
{
l = this.getMaxCurrentStrength(worldIn, blockpos.down(), l);
}
}
if (l > j)
{
j = l - 1;
}
else if (j > 0)
{
--j;
}
else
{
j = 0;
}
if (k > j - 1)
{
j = k;
}
if (i != j)
{
state = state.withProperty(POWER, Integer.valueOf(j));
if (worldIn.getState(pos1) == iblockstate)
{
worldIn.setState(pos1, state, 2);
}
this.blocksNeedingUpdate.add(pos1);
for (Facing enumfacing1 : Facing.values())
{
this.blocksNeedingUpdate.add(pos1.offset(enumfacing1));
}
}
return state;
}
/**
* Calls World.notifyNeighborsOfStateChange() for all neighboring blocks, but only if the given block is a
* wire.
*/
private void notifyWireNeighborsOfStateChange(World worldIn, BlockPos pos)
{
if (worldIn.getState(pos).getBlock() == this)
{
worldIn.notifyNeighborsOfStateChange(pos, this);
for (Facing enumfacing : Facing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
if (!worldIn.client)
{
this.updateSurroundings(worldIn, pos, state);
for (Facing enumfacing : Facing.Plane.VERTICAL)
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
for (Facing enumfacing1 : Facing.Plane.HORIZONTAL)
{
this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(enumfacing1));
}
for (Facing enumfacing2 : Facing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing2);
if (worldIn.getState(blockpos).getBlock().isNormalCube())
{
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up());
}
else
{
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down());
}
}
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockRemoved(worldIn, pos, state);
if (!worldIn.client)
{
for (Facing enumfacing : Facing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
this.updateSurroundings(worldIn, pos, state);
for (Facing enumfacing1 : Facing.Plane.HORIZONTAL)
{
this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(enumfacing1));
}
for (Facing enumfacing2 : Facing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing2);
if (worldIn.getState(blockpos).getBlock().isNormalCube())
{
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up());
}
else
{
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down());
}
}
}
}
private int getMaxCurrentStrength(World worldIn, BlockPos pos, int strength)
{
if (worldIn.getState(pos).getBlock() != this)
{
return strength;
}
else
{
int i = ((Integer)worldIn.getState(pos).getValue(POWER)).intValue();
return i > strength ? i : strength;
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.client)
{
if (this.canPlaceBlockAt(worldIn, pos))
{
this.updateSurroundings(worldIn, pos, state);
}
else
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return this.getItem();
}
private boolean isConnectedTo(IBlockAccess worldIn, BlockPos pos, Facing side)
{
BlockPos blockpos = pos.offset(side);
State iblockstate = worldIn.getState(blockpos);
Block block = iblockstate.getBlock();
boolean flag = block.isNormalCube();
boolean flag1 = worldIn.getState(pos.up()).getBlock().isNormalCube();
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 boolean canConnectUpwardsTo(IBlockAccess worldIn, BlockPos pos)
{
return this.canConnectUpwardsTo(worldIn.getState(pos));
}
protected boolean canConnectUpwardsTo(State state)
{
return this.canConnectTo(state, (Facing)null);
}
protected boolean canConnectTo(State blockState, Facing side)
{
Block block = blockState.getBlock();
if (block == this)
{
return true;
}
// else if (Blocks.repeater.isAssociated(block))
// {
// Facing enumfacing = (Facing)blockState.getValue(BlockwireRepeater.FACING);
// return enumfacing == side || enumfacing.getOpposite() == side;
// }
else
{
return block.canConnectToWire() && side != null;
}
}
public double doPowerPhase(AWorldServer world, BlockPos pos, Random rand, double voltage, double currentLimit) { // TODO: implement
Queue<BlockPos> queue = new ArrayDeque<BlockPos>();
@ -574,7 +294,7 @@ public class BlockWire extends Block
if(!traversed.contains(bpos)) {
traversed.add(bpos);
State state = world.getState(bpos);
if(state.getBlock().canConnectToWire() || state.getBlock() instanceof BlockWire) {
if(state.getBlock().canConnectToWire(this.getState())) {
double power = state.getBlock().powerTick(world, bpos, state, rand, voltage, currentLimit);
converted += power;
voltage -= state.getBlock().getResistance(world, bpos, state) * (power / voltage);
@ -598,14 +318,9 @@ public class BlockWire extends Block
return 0.01;
}
// public boolean canConnectToWire()
// {
// return true;
// }
public Item getItem(World worldIn, BlockPos pos)
public boolean canConnectToWire(State state)
{
return this.getItem();
return state.getBlock() == this;
}
public BlockLayer getBlockLayer()
@ -615,26 +330,27 @@ public class BlockWire extends Block
protected Property[] getProperties()
{
return new Property[] {NORTH, EAST, SOUTH, WEST, POWER};
return new Property[] {DOWN, UP, NORTH, EAST, SOUTH, WEST};
}
public boolean isMagnetic() {
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
boolean na = state.getValue(NORTH) == EnumAttachPosition.NONE;
boolean sa = state.getValue(SOUTH) == EnumAttachPosition.NONE;
boolean wa = state.getValue(WEST) == EnumAttachPosition.NONE;
boolean ea = state.getValue(EAST) == EnumAttachPosition.NONE;
boolean nu = state.getValue(NORTH) == EnumAttachPosition.UP;
boolean su = state.getValue(SOUTH) == EnumAttachPosition.UP;
boolean wu = state.getValue(WEST) == EnumAttachPosition.UP;
boolean eu = state.getValue(EAST) == EnumAttachPosition.UP;
boolean nr = state.getValue(NORTH) == EnumAttachPosition.SIDE;
boolean sr = state.getValue(SOUTH) == EnumAttachPosition.SIDE;
boolean wr = state.getValue(WEST) == EnumAttachPosition.SIDE;
boolean er = state.getValue(EAST) == EnumAttachPosition.SIDE;
public Model getModel(ModelProvider provider, String name, State state) { //TODO: fix model
boolean nr = state.getValue(NORTH);
boolean sr = state.getValue(SOUTH);
boolean wr = state.getValue(WEST);
boolean er = state.getValue(EAST);
boolean na = !nr;
boolean sa = !sr;
boolean wa = !wr;
boolean ea = !er;
boolean ud = state.getValue(DOWN) || state.getValue(UP);
boolean nu = nr && ud;
boolean su = sr && ud;
boolean wu = wr && ud;
boolean eu = er && ud;
if(ea && na && sa && wa)
return wire_none;
@ -818,40 +534,12 @@ public class BlockWire extends Block
else
return wire_none;
}
public Property<?>[] getIgnoredProperties() {
return new Property[] {POWER};
}
protected Item getItemToRegister() {
return new ItemWire(this);
return super.getItemToRegister().setMaxAmount(StackSize.XL);
}
public Property[] getUnsavedProperties() {
return new Property[] {EAST, NORTH, SOUTH, WEST};
return new Property[] {DOWN, UP, EAST, NORTH, SOUTH, WEST};
}
public static enum EnumAttachPosition implements Identifyable
{
UP("up"),
SIDE("side"),
NONE("none");
private final String name;
private EnumAttachPosition(String name)
{
this.name = name;
}
public String toString()
{
return this.getName();
}
public String getName()
{
return this.name;
}
}
}

View file

@ -1,11 +1,11 @@
package common.block.tile;
import common.block.BlockContainer;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.Item;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
@ -16,7 +16,7 @@ import common.world.IBlockAccess;
import common.world.State;
import common.world.World;
public class BlockSign extends BlockContainer
public class BlockSign extends Block implements ITileEntityProvider
{
public BlockSign()
{
@ -85,15 +85,7 @@ public class BlockSign extends BlockContainer
return new TileEntitySign();
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.sign;
}
public Item getItem(World worldIn, BlockPos pos)
public Item getItem()
{
return Items.sign;
}
@ -122,6 +114,15 @@ public class BlockSign extends BlockContainer
// super.onBlockRemoved(worldIn, pos, state);
// }
private boolean isInvalidNeighbor(World world, BlockPos pos, Facing face) {
return world.getState(pos.offset(face)).getBlock().getMaterial() == Material.BLOCKING;
}
private boolean hasInvalidNeighbor(World world, BlockPos pos) {
return this.isInvalidNeighbor(world, pos, Facing.NORTH) || this.isInvalidNeighbor(world, pos, Facing.SOUTH)
|| this.isInvalidNeighbor(world, pos, Facing.WEST) || this.isInvalidNeighbor(world, pos, Facing.EAST);
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return !this.hasInvalidNeighbor(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos);
@ -135,4 +136,8 @@ public class BlockSign extends BlockContainer
public String getFallbackTexture() {
return "oak_planks";
}
public int getRenderType() {
return -1;
}
}

View file

@ -125,24 +125,21 @@ public class EntityFalling extends Entity implements IObjectData
this.motionZ *= 0.699999988079071D;
this.motionY *= -0.5D;
if (this.worldObj.getState(blockpos1).getBlock() != Blocks.piston_extension)
{
this.setDead();
this.setDead();
if (!this.canSetAsBlock)
if (!this.canSetAsBlock)
{
if (this.worldObj.canBlockBePlaced(block, blockpos1, true, Facing.UP, (Entity)null, (ItemStack)null) && !BlockFalling.canFallInto(this.worldObj, blockpos1.down()) && this.worldObj.setState(blockpos1, this.fallTile, 3))
{
if (this.worldObj.canBlockBePlaced(block, blockpos1, true, Facing.UP, (Entity)null, (ItemStack)null) && !BlockFalling.canFallInto(this.worldObj, blockpos1.down()) && this.worldObj.setState(blockpos1, this.fallTile, 3))
if (block instanceof BlockFalling)
{
if (block instanceof BlockFalling)
{
((BlockFalling)block).onEndFalling(this.worldObj, blockpos1);
}
}
else if (this.shouldDropItem && Vars.objectDrop)
{
this.entityDropItem(new ItemStack(block.getItem()), 0.0F);
((BlockFalling)block).onEndFalling(this.worldObj, blockpos1);
}
}
else if (this.shouldDropItem && Vars.objectDrop)
{
this.entityDropItem(new ItemStack(block.getItem()), 0.0F);
}
}
}
else if (this.fallTime > 100 && !this.worldObj.client && (blockpos1.getY() < -World.MAX_SIZE_Y + 1 || blockpos1.getY() > World.MAX_SIZE_Y) || this.fallTime > 600)

View file

@ -111,7 +111,6 @@ import common.block.tech.BlockMobSpawner;
import common.block.tech.BlockNuke;
import common.block.tech.BlockPistonBase;
import common.block.tech.BlockPistonHead;
import common.block.tech.BlockPistonMoving;
import common.block.tech.BlockPressurePlate;
import common.block.tech.BlockPressurePlateWeighted;
import common.block.tech.BlockRail;
@ -359,7 +358,7 @@ public abstract class BlockRegistry {
}
Block cactus = (new BlockCactus()).setHardness(0.4F).setStepSound(SoundType.CLOTH).setDisplay("Kaktus");
register("cactus", cactus);
register("reeds", (new BlockReed()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Zuckerrohr"));
register("reeds", (new BlockReed()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Zuckerrohr").setTab(CheatTab.PLANTS));
register("vine", (new BlockVine()).setHardness(0.2F).setStepSound(SoundType.GRASS).setDisplay("Ranken").setShearsEfficiency(0));
register("waterlily", (new BlockLilyPad()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Seerosenblatt"));
register("cocoa", (new BlockCocoa()).setHardness(0.2F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay("Kakao"));
@ -369,11 +368,11 @@ public abstract class BlockRegistry {
Block brownMushroom = (new BlockMushroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.125F)
.setDisplay("Pilz");
register("brown_mushroom", brownMushroom);
register("brown_mushroom_block", (new BlockHugeMushroom(Material.WOOD, brownMushroom)).setHardness(0.2F)
register("brown_mushroom_block", (new BlockHugeMushroom(brownMushroom)).setHardness(0.2F)
.setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS));
Block redMushrooom = (new BlockMushroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Pilz");
register("red_mushroom", redMushrooom);
register("red_mushroom_block", (new BlockHugeMushroom(Material.WOOD, redMushrooom)).setHardness(0.2F)
register("red_mushroom_block", (new BlockHugeMushroom(redMushrooom)).setHardness(0.2F)
.setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS));
register("blue_mushroom", (new BlockBlueShroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.5F)
.setDisplay("Tianpilz"));
@ -414,7 +413,7 @@ public abstract class BlockRegistry {
for(DyeColor color : DyeColor.values()) {
register(color.getName() + "_glass", (new BlockStainedGlass(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getDisplay() + " gefärbtes Glas"));
}
register("glass_pane", (new BlockPane(Material.TRANSLUCENT, false)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glasscheibe"));
register("glass_pane", (new BlockPane(Material.TRANSLUCENT)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glasscheibe"));
for(DyeColor color : DyeColor.values()) {
register(color.getName() + "_glass_pane", (new BlockStainedGlassPane(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getDisplay() + " gefärbte Glasscheibe"));
}
@ -433,10 +432,10 @@ public abstract class BlockRegistry {
register("ladder", (new BlockLadder()).setHardness(0.4F).setStepSound(SoundType.LADDER).setDisplay("Leiter").setAxeHarvestable());
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("cake", (new BlockCake()).setHardness(0.5F).setStepSound(SoundType.CLOTH).setDisplay("Kuchen").setTab(CheatTab.DECORATION));
register("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setStepSound(SoundType.STONE)
.setLightLevel(0.125F).setDisplay("Drachenei").setTab(CheatTab.DECORATION));
register("flowerpot", (new BlockFlowerPot(null)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf"));
register("flowerpot", (new BlockFlowerPot(null)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf").setTab(CheatTab.DECORATION));
register("flowerpot_cactus", (new BlockFlowerPot(cactus)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf mit " + cactus.getDisplay()));
for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) {
register("flowerpot_" + type.getName(), (new BlockFlowerPot(BlockFlower.getByType(type))).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf mit " + type.getDisplay()));
@ -510,7 +509,7 @@ public abstract class BlockRegistry {
"quartz_block_bottom", "quartz_top"))
.setDisplay("Quarztreppe"));
register("iron_bars", (new BlockPane(Material.SOLID, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
register("iron_bars", (new BlockPane(Material.SOLID)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
.setDisplay("Eisengitter"));
register("iron_trapdoor", (new BlockTrapDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisenfalltür"));
@ -603,8 +602,8 @@ public abstract class BlockRegistry {
register("anvil" + (z == 0 ? "" : "_damaged_" + z), (new BlockAnvil(z)).setHardness(5.0F).setStepSound(SoundType.ANVIL).setResistance(2000.0F).setDisplay((z == 0 ? "" : (z == 1 ? "Leicht beschädigter " : "Stark beschädigter ")) + "Amboss"));
}
register("enchanting_table", (new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setDisplay("Zaubertisch"));
register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand"));
register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel"));
register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand").setTab(CheatTab.TECHNOLOGY));
register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel").setTab(CheatTab.TECHNOLOGY));
register("effect_generator", (new BlockEffectGenerator()).setDisplay("Effektgenerator").setLightLevel(1.0F));
register("construction_table", (new BlockWorkbench(4)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Konstruktionstisch"));
register("assembly_unit", (new BlockWorkbench(5)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Fertigungseinheit"));
@ -627,8 +626,8 @@ public abstract class BlockRegistry {
register("piston", (new BlockPistonBase(false)).setDisplay("Kolben"));
register("sticky_piston", (new BlockPistonBase(true)).setDisplay("Klebriger Kolben"));
register("piston_head", (new BlockPistonHead()).setDisplay("Kolben"));
register("piston_extension", new BlockPistonMoving().setDisplay("Kolben"));
register("piston_head", (new BlockPistonHead(false)).setDisplay("Kolben"));
register("sticky_piston_head", (new BlockPistonHead(true)).setDisplay("Klebriger Kolben"));
register("dispenser", (new BlockDispenser()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Werfer"));
register("dropper", (new BlockDropper()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Spender"));
register("hopper", (new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Trichter"));
@ -651,7 +650,7 @@ 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("wire", (new BlockWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Kabel"));
register("wire", (new BlockWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Kabel").setTab(CheatTab.TECHNOLOGY));
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"));
@ -669,7 +668,7 @@ public abstract class BlockRegistry {
register("daylight_detector", new BlockDaylightDetector(false).setDisplay("Tageslichtsensor"));
register("daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor"));
register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));
register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0));
register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0).setTab(CheatTab.TECHNOLOGY));
register("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisentür"));
for(WoodType wood : WoodType.values()) {

View file

@ -387,8 +387,8 @@ public abstract class Blocks {
public static final BlockFlower pink_tulip = get("pink_tulip");
public static final BlockWool pink_wool = get("pink_wool");
public static final BlockPistonBase piston = get("piston");
public static final BlockPistonMoving piston_extension = get("piston_extension");
public static final BlockPistonHead piston_head = get("piston_head");
public static final BlockPistonHead sticky_piston_head = get("sticky_piston_head");
public static final Block platinum_block = get("platinum_block");
public static final BlockOre platinum_ore = get("platinum_ore");
public static final Block plutonium_block = get("plutonium_block");

View file

@ -275,7 +275,9 @@ public abstract class ItemRegistry {
}
Item lapis = null;
for(DyeColor color : DyeColor.values()) {
Item dye = (new ItemDye(color)).setDisplay(color.getDyeName()).setMaxAmount(StackSize.XXL);
if(color == DyeColor.BROWN)
continue;
Item dye = new ItemDye(color, null);
if(color == DyeColor.BLUE)
lapis = dye;
register(color.getDye(), dye);

Some files were not shown because too many files have changed in this diff Show more