start of offering table

This commit is contained in:
Ellpeck 2018-11-19 20:18:22 +01:00
parent 6d0a14e3c4
commit 8647425de6
11 changed files with 1451 additions and 7 deletions

View file

@ -134,13 +134,7 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, IMod
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityImpl) {
TileEntityImpl impl = (TileEntityImpl) tile;
boolean powered = world.getRedstonePowerFromNeighbors(pos) > 0;
boolean wasPowered = impl.isRedstonePowered;
if (powered && !wasPowered) {
impl.isRedstonePowered = true;
} else if (!powered && wasPowered) {
impl.isRedstonePowered = false;
}
impl.isRedstonePowered = world.getRedstonePowerFromNeighbors(pos) > 0;
}
}
}

View file

@ -0,0 +1,61 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockOfferingTable extends BlockContainerImpl {
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
public BlockOfferingTable() {
super(Material.WOOD, "offering_table", TileEntityOfferingTable.class, "offering_table");
this.setSoundType(SoundType.WOOD);
this.setHardness(2F);
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BOUND_BOX;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
return false;
}
@Override
public boolean isSideSolid(IBlockState baseState, IBlockAccess world, BlockPos pos, EnumFacing side) {
return false;
}
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
return BlockFaceShape.UNDEFINED;
}
}

View file

@ -34,4 +34,5 @@ public final class ModBlocks {
public static final Block FIELD_CREATOR = new BlockFieldCreator();
public static final Block OAK_GENERATOR = new BlockOakGenerator();
public static final Block INFUSED_IRON = new BlockImpl("infused_iron_block", Material.IRON).setSoundType(SoundType.METAL).setHardness(3F);
public static final Block OFFERING_TABLE = new BlockOfferingTable();
}

View file

@ -0,0 +1,32 @@
package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
public class TileEntityOfferingTable extends TileEntityImpl {
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true);
@Override
public void writeNBT(NBTTagCompound compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
compound.setTag("items", this.items.serializeNBT());
}
}
@Override
public void readNBT(NBTTagCompound compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
this.items.deserializeNBT(compound.getCompoundTag("items"));
}
}
@Override
public IItemHandlerModifiable getItemHandler(EnumFacing facing) {
return this.items;
}
}

View file

@ -0,0 +1,53 @@
package de.ellpeck.naturesaura.blocks.tiles.render;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.math.MathHelper;
import java.util.Random;
public class RenderOfferingTable extends TileEntitySpecialRenderer<TileEntityOfferingTable> {
private final Random rand = new Random();
@Override
public void render(TileEntityOfferingTable tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
ItemStack stack = tile.items.getStackInSlot(0);
if (!stack.isEmpty()) {
this.rand.setSeed(Item.getIdFromItem(stack.getItem()) + stack.getMetadata());
int amount = MathHelper.ceil(stack.getCount() / 8F);
for (int i = 0; i < amount; i++) {
GlStateManager.pushMatrix();
Item item = stack.getItem();
float scale;
float yOff;
if (item instanceof ItemBlock && ((ItemBlock) item).getBlock().getRenderLayer() == BlockRenderLayer.SOLID) {
scale = 0.4F;
yOff = 0.08F;
} else {
scale = 0.25F;
yOff = 0F;
}
GlStateManager.translate(
x + 0.35F + this.rand.nextFloat() * 0.3F,
y + 0.9F + yOff + (i * 0.001F),
z + 0.35F + this.rand.nextFloat() * 0.3F);
GlStateManager.rotate(this.rand.nextFloat() * 360F, 0F, 1F, 0F);
GlStateManager.rotate(90F, 1F, 0F, 0F);
GlStateManager.scale(scale, scale, scale);
Helper.renderItemInWorld(stack);
GlStateManager.popMatrix();
}
}
}
}

View file

@ -1,8 +1,10 @@
package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.particles.ParticleHandler;
@ -38,6 +40,7 @@ public class ClientProxy implements IProxy {
public void init(FMLInitializationEvent event) {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWoodStand.class, new RenderWoodStand());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityNatureAltar.class, new RenderNatureAltar());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityOfferingTable.class, new RenderOfferingTable());
Map<String, RenderPlayer> skinMap = Minecraft.getMinecraft().getRenderManager().getSkinMap();
for (RenderPlayer render : new RenderPlayer[]{skinMap.get("default"), skinMap.get("slim")}) {

View file

@ -0,0 +1,17 @@
{
"forge_marker": 1,
"defaults": {
"model": "naturesaura:offering_table",
"textures": {
"0": "naturesaura:blocks/stripped_oak_log",
"1": "naturesaura:blocks/stripped_oak_log_top",
"2": "naturesaura:blocks/infused_stone",
"particle": "#0"
},
"transform": "forge:default-block"
},
"variants": {
"normal": [{}],
"inventory": [{}]
}
}

View file

@ -31,6 +31,7 @@ tile.naturesaura.hopper_upgrade.name=Hopper Enhancement
tile.naturesaura.field_creator.name=Aura Field Creator
tile.naturesaura.oak_generator.name=Canopy Diminisher
tile.naturesaura.infused_iron_block.name=Infused Iron Block
tile.naturesaura.offering_table.name=Offering Table
item.naturesaura.eye.name=Environmental Eye
item.naturesaura.gold_fiber.name=Brilliant Fiber

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B