mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
More porting of blocks
This commit is contained in:
parent
06a2957f27
commit
4d5cc7aa58
7 changed files with 480 additions and 510 deletions
|
@ -1,4 +1,7 @@
|
||||||
package de.ellpeck.actuallyadditions.client;
|
package de.ellpeck.actuallyadditions.client;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||||
|
|
||||||
public class ClientSetup {
|
public class ClientSetup {
|
||||||
|
GuiUtils
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,30 @@
|
||||||
package de.ellpeck.actuallyadditions.common.blocks;
|
package de.ellpeck.actuallyadditions.common.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.metalists.TheColoredLampColors;
|
import de.ellpeck.actuallyadditions.common.blocks.metalists.TheColoredLampColors;
|
||||||
import de.ellpeck.actuallyadditions.common.util.StackUtil;
|
import de.ellpeck.actuallyadditions.common.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.common.util.StringUtil;
|
import de.ellpeck.actuallyadditions.common.util.StringUtil;
|
||||||
import de.ellpeck.actuallyadditions.common.util.Util;
|
import de.ellpeck.actuallyadditions.common.util.Util;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
public class BlockColoredLamp extends Block {
|
public class BlockColoredLamp extends Block {
|
||||||
|
|
||||||
public static final TheColoredLampColors[] ALL_LAMP_TYPES = TheColoredLampColors.values();
|
// todo: replace with flattered versions
|
||||||
public static final PropertyEnum<TheColoredLampColors> TYPE = PropertyEnum.create("type", TheColoredLampColors.class);
|
// public static final TheColoredLampColors[] ALL_LAMP_TYPES = TheColoredLampColors.values();
|
||||||
|
// public static final PropertyEnum<TheColoredLampColors> TYPE = PropertyEnum.create("type", TheColoredLampColors.class);
|
||||||
public final boolean isOn;
|
public final boolean isOn;
|
||||||
|
|
||||||
public BlockColoredLamp(boolean isOn) {
|
public BlockColoredLamp(boolean isOn) {
|
||||||
|
@ -43,113 +35,96 @@ public class BlockColoredLamp extends Block {
|
||||||
this.isOn = isOn;
|
this.isOn = isOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public Item getItemDropped(Block block) {
|
||||||
|
// return Item.getItemFromBlock(InitBlocks.blockColoredLamp);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public int damageDropped(BlockState state) {
|
||||||
|
// return this.getMetaFromState(state);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// todo: re-implement
|
||||||
@Override
|
@Override
|
||||||
public Item getItemDropped(IBlockState state, Random rand, int par3) {
|
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
return Item.getItemFromBlock(InitBlocks.blockColoredLamp);
|
// ItemStack stack = player.getHeldItem(hand);
|
||||||
|
// //Turning On
|
||||||
|
// if (hand == EnumHand.MAIN_HAND && stack.isEmpty()) {
|
||||||
|
// world.setBlockState(pos, (this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn).getDefaultState().withProperty(TYPE, state.getValue(TYPE)), 2);
|
||||||
|
// world.notifyLightSet(pos);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (StackUtil.isValid(stack)) {
|
||||||
|
// //Changing Colors
|
||||||
|
// int[] oreIDs = OreDictionary.getOreIDs(stack);
|
||||||
|
// if (oreIDs.length > 0) {
|
||||||
|
// for (int oreID : oreIDs) {
|
||||||
|
// String name = OreDictionary.getOreName(oreID);
|
||||||
|
// TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
|
||||||
|
// if (color != null) {
|
||||||
|
// if (this.getMetaFromState(state) != color.ordinal()) {
|
||||||
|
// if (!world.isRemote) {
|
||||||
|
// world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2);
|
||||||
|
// if (!player.capabilities.isCreativeMode) {
|
||||||
|
// player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public int damageDropped(IBlockState state) {
|
// @SideOnly(Side.CLIENT)
|
||||||
return this.getMetaFromState(state);
|
// public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||||
}
|
// for (int j = 0; j < ALL_LAMP_TYPES.length; j++) {
|
||||||
|
// list.add(new ItemStack(this, 1, j));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public int getLightValue(BlockState state) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
|
||||||
//Turning On
|
|
||||||
if (hand == EnumHand.MAIN_HAND && stack.isEmpty()) {
|
|
||||||
world.setBlockState(pos, (this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn).getDefaultState().withProperty(TYPE, state.getValue(TYPE)), 2);
|
|
||||||
world.notifyLightSet(pos);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StackUtil.isValid(stack)) {
|
|
||||||
//Changing Colors
|
|
||||||
int[] oreIDs = OreDictionary.getOreIDs(stack);
|
|
||||||
if (oreIDs.length > 0) {
|
|
||||||
for (int oreID : oreIDs) {
|
|
||||||
String name = OreDictionary.getOreName(oreID);
|
|
||||||
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
|
|
||||||
if (color != null) {
|
|
||||||
if (this.getMetaFromState(state) != color.ordinal()) {
|
|
||||||
if (!world.isRemote) {
|
|
||||||
world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2);
|
|
||||||
if (!player.capabilities.isCreativeMode) {
|
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
||||||
for (int j = 0; j < ALL_LAMP_TYPES.length; j++) {
|
|
||||||
list.add(new ItemStack(this, 1, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
||||||
return this.isOn ? 15 : 0;
|
return this.isOn ? 15 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected BlockItemBase getItemBlock() {
|
// public void registerRendering() {
|
||||||
return new TheItemBlock(this);
|
// for (int i = 0; i < ALL_LAMP_TYPES.length; i++) {
|
||||||
}
|
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_LAMP_TYPES[i].regName);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void registerRendering() {
|
// protected BlockStateContainer createBlockState() {
|
||||||
for (int i = 0; i < ALL_LAMP_TYPES.length; i++) {
|
// return new BlockStateContainer(this, TYPE);
|
||||||
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_LAMP_TYPES[i].regName);
|
// }
|
||||||
}
|
//
|
||||||
}
|
// public static class TheItemBlock extends BlockItem {
|
||||||
|
//
|
||||||
@Override
|
// public TheItemBlock(Block block) {
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
// super(block);
|
||||||
return EnumRarity.RARE;
|
// this.setHasSubtypes(true);
|
||||||
}
|
// this.setMaxDamage(0);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
// @Override
|
||||||
return this.getDefaultState().withProperty(TYPE, TheColoredLampColors.values()[meta]);
|
// public String getItemStackDisplayName(ItemStack stack) {
|
||||||
}
|
// if (stack.getItemDamage() >= ALL_LAMP_TYPES.length) { return StringUtil.BUGGED_ITEM_NAME; }
|
||||||
|
// if (Util.isClient()) return super.getItemStackDisplayName(stack) + (((BlockColoredLamp) this.block).isOn ? " (" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".onSuffix.desc") + ")" : "");
|
||||||
@Override
|
// else return super.getItemStackDisplayName(stack);
|
||||||
public int getMetaFromState(IBlockState state) {
|
// }
|
||||||
return state.getValue(TYPE).ordinal();
|
//
|
||||||
}
|
// @Override
|
||||||
|
// public String getTranslationKey(ItemStack stack) {
|
||||||
@Override
|
// return InitBlocks.blockColoredLamp.getTranslationKey() + "_" + ALL_LAMP_TYPES[stack.getItemDamage()].regName;
|
||||||
protected BlockStateContainer createBlockState() {
|
// }
|
||||||
return new BlockStateContainer(this, TYPE);
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
public static class TheItemBlock extends BlockItem {
|
|
||||||
|
|
||||||
public TheItemBlock(Block block) {
|
|
||||||
super(block);
|
|
||||||
this.setHasSubtypes(true);
|
|
||||||
this.setMaxDamage(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItemStackDisplayName(ItemStack stack) {
|
|
||||||
if (stack.getItemDamage() >= ALL_LAMP_TYPES.length) { return StringUtil.BUGGED_ITEM_NAME; }
|
|
||||||
if (Util.isClient()) return super.getItemStackDisplayName(stack) + (((BlockColoredLamp) this.block).isOn ? " (" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".onSuffix.desc") + ")" : "");
|
|
||||||
else return super.getItemStackDisplayName(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTranslationKey(ItemStack stack) {
|
|
||||||
return InitBlocks.blockColoredLamp.getTranslationKey() + "_" + ALL_LAMP_TYPES[stack.getItemDamage()].regName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,213 +1,214 @@
|
||||||
package de.ellpeck.actuallyadditions.common.blocks;
|
// todo: remove
|
||||||
|
//package de.ellpeck.actuallyadditions.common.blocks;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
|
//
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
|
//import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
|
||||||
import de.ellpeck.actuallyadditions.common.tile.TileEntityCompost;
|
//import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.common.util.AssetUtil;
|
//import de.ellpeck.actuallyadditions.common.tile.TileEntityCompost;
|
||||||
import de.ellpeck.actuallyadditions.common.util.ItemUtil;
|
//import de.ellpeck.actuallyadditions.common.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.common.util.StackUtil;
|
//import de.ellpeck.actuallyadditions.common.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.common.util.StringUtil;
|
//import de.ellpeck.actuallyadditions.common.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
//import de.ellpeck.actuallyadditions.common.util.StringUtil;
|
||||||
import net.minecraft.block.SoundType;
|
//import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
//import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
//import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
//import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.client.Minecraft;
|
//import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.gui.ScaledResolution;
|
//import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
//import net.minecraft.client.gui.ScaledResolution;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
//import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.EnumRarity;
|
//import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.state.IProperty;
|
//import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
//import net.minecraft.state.IProperty;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
//import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
//import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.EnumHand;
|
//import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
//import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
//import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
//import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
//import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.IBlockAccess;
|
//import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.world.World;
|
//import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.common.ToolType;
|
//import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
//import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
//import net.minecraftforge.common.property.ExtendedBlockState;
|
||||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
//import net.minecraftforge.common.property.IExtendedBlockState;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
//import net.minecraftforge.common.property.IUnlistedProperty;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
//import net.minecraftforge.fml.relauncher.Side;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
//import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
//import org.apache.commons.lang3.tuple.Pair;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
public class BlockCompost extends BlockContainerBase implements IHudDisplay {
|
//
|
||||||
|
//public class BlockCompost extends BlockContainerBase implements IHudDisplay {
|
||||||
protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D);
|
//
|
||||||
protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
|
// protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D);
|
||||||
protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
|
// protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
|
||||||
protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
// protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
|
||||||
protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
|
// protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1 - 0.0625, 11 * 0.0625, 1 - 0.0625);
|
// protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
|
||||||
|
// private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1 - 0.0625, 11 * 0.0625, 1 - 0.0625);
|
||||||
public BlockCompost() {
|
//
|
||||||
super(Block.Properties.create(Material.WOOD)
|
// public BlockCompost() {
|
||||||
.hardnessAndResistance(0.5f, 5.0f)
|
// super(Block.Properties.create(Material.WOOD)
|
||||||
.harvestTool(ToolType.AXE)
|
// .hardnessAndResistance(0.5f, 5.0f)
|
||||||
.sound(SoundType.WOOD));
|
// .harvestTool(ToolType.AXE)
|
||||||
}
|
// .sound(SoundType.WOOD));
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
// @Override
|
||||||
return AABB;
|
// public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
}
|
// return AABB;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
@Deprecated
|
// @Override
|
||||||
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean someBool) {
|
// @Deprecated
|
||||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS);
|
// public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean someBool) {
|
||||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST);
|
// addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS);
|
||||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH);
|
// addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST);
|
||||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST);
|
// addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH);
|
||||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH);
|
// addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST);
|
||||||
}
|
// addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean isOpaqueCube(IBlockState state) {
|
// @Override
|
||||||
return false;
|
// public boolean isOpaqueCube(IBlockState state) {
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean isFullCube(IBlockState state) {
|
// @Override
|
||||||
return false;
|
// public boolean isFullCube(IBlockState state) {
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9) {
|
// @Override
|
||||||
ItemStack stackPlayer = player.getHeldItem(hand);
|
// public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9) {
|
||||||
if (!world.isRemote) {
|
// ItemStack stackPlayer = player.getHeldItem(hand);
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
// if (!world.isRemote) {
|
||||||
if (tile instanceof TileEntityCompost) {
|
// TileEntity tile = world.getTileEntity(pos);
|
||||||
TileEntityCompost compost = (TileEntityCompost) tile;
|
// if (tile instanceof TileEntityCompost) {
|
||||||
ItemStack slot = compost.inv.getStackInSlot(0);
|
// TileEntityCompost compost = (TileEntityCompost) tile;
|
||||||
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
|
// ItemStack slot = compost.inv.getStackInSlot(0);
|
||||||
if (!StackUtil.isValid(slot) || recipeIn != null) {
|
// CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
|
||||||
if (StackUtil.isValid(stackPlayer)) {
|
// if (!StackUtil.isValid(slot) || recipeIn != null) {
|
||||||
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
|
// if (StackUtil.isValid(stackPlayer)) {
|
||||||
if (recipeHand != null && (recipeIn == null || recipeIn == recipeHand)) {
|
// CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
|
||||||
int maxAdd = stackPlayer.getCount();
|
// if (recipeHand != null && (recipeIn == null || recipeIn == recipeHand)) {
|
||||||
|
// int maxAdd = stackPlayer.getCount();
|
||||||
if (!StackUtil.isValid(slot)) {
|
//
|
||||||
ItemStack stackToAdd = stackPlayer.copy();
|
// if (!StackUtil.isValid(slot)) {
|
||||||
stackToAdd.setCount(maxAdd);
|
// ItemStack stackToAdd = stackPlayer.copy();
|
||||||
compost.inv.setStackInSlot(0, stackToAdd);
|
// stackToAdd.setCount(maxAdd);
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
|
// compost.inv.setStackInSlot(0, stackToAdd);
|
||||||
return true;
|
// player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
|
||||||
} else {
|
// return true;
|
||||||
ItemStack stackIn = slot.copy();
|
// } else {
|
||||||
if (stackIn.getCount() < slot.getMaxStackSize()) {
|
// ItemStack stackIn = slot.copy();
|
||||||
int sizeAdded = Math.min(maxAdd, slot.getMaxStackSize() - stackIn.getCount());
|
// if (stackIn.getCount() < slot.getMaxStackSize()) {
|
||||||
stackIn.grow(sizeAdded);
|
// int sizeAdded = Math.min(maxAdd, slot.getMaxStackSize() - stackIn.getCount());
|
||||||
compost.inv.setStackInSlot(0, stackIn);
|
// stackIn.grow(sizeAdded);
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
|
// compost.inv.setStackInSlot(0, stackIn);
|
||||||
return true;
|
// player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
|
||||||
}
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
// }
|
||||||
if (!StackUtil.isValid(stackPlayer)) {
|
// } else {
|
||||||
player.setHeldItem(hand, slot.copy());
|
// if (!StackUtil.isValid(stackPlayer)) {
|
||||||
compost.inv.setStackInSlot(0, StackUtil.getEmpty());
|
// player.setHeldItem(hand, slot.copy());
|
||||||
return true;
|
// compost.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
} else if (ItemUtil.canBeStacked(stackPlayer, slot)) {
|
// return true;
|
||||||
int addedStackSize = Math.min(slot.getCount(), stackPlayer.getMaxStackSize() - stackPlayer.getCount());
|
// } else if (ItemUtil.canBeStacked(stackPlayer, slot)) {
|
||||||
ItemStack stackToAdd = stackPlayer.copy();
|
// int addedStackSize = Math.min(slot.getCount(), stackPlayer.getMaxStackSize() - stackPlayer.getCount());
|
||||||
stackToAdd.grow(addedStackSize);
|
// ItemStack stackToAdd = stackPlayer.copy();
|
||||||
player.setHeldItem(hand, stackToAdd);
|
// stackToAdd.grow(addedStackSize);
|
||||||
compost.inv.getStackInSlot(0).shrink(addedStackSize);
|
// player.setHeldItem(hand, stackToAdd);
|
||||||
return true;
|
// compost.inv.getStackInSlot(0).shrink(addedStackSize);
|
||||||
|
// return true;
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
tile.markDirty();
|
// }
|
||||||
world.notifyBlockUpdate(pos, this.getDefaultState(), this.getDefaultState(), 3);
|
// tile.markDirty();
|
||||||
}
|
// world.notifyBlockUpdate(pos, this.getDefaultState(), this.getDefaultState(), 3);
|
||||||
} else {
|
// }
|
||||||
return true;
|
// } else {
|
||||||
}
|
// return true;
|
||||||
return false;
|
// }
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public TileEntity createNewTileEntity(World world, int meta) {
|
// @Override
|
||||||
return new TileEntityCompost();
|
// public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
}
|
// return new TileEntityCompost();
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
// @Override
|
||||||
return EnumRarity.UNCOMMON;
|
// public EnumRarity getRarity(ItemStack stack) {
|
||||||
}
|
// return EnumRarity.UNCOMMON;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
@SideOnly(Side.CLIENT)
|
// @Override
|
||||||
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
|
// @SideOnly(Side.CLIENT)
|
||||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
// public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
|
||||||
if (tile instanceof TileEntityCompost) {
|
// TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||||
ItemStack slot = ((TileEntityCompost) tile).inv.getStackInSlot(0);
|
// if (tile instanceof TileEntityCompost) {
|
||||||
String strg;
|
// ItemStack slot = ((TileEntityCompost) tile).inv.getStackInSlot(0);
|
||||||
if (!StackUtil.isValid(slot)) {
|
// String strg;
|
||||||
strg = "Empty";
|
// if (!StackUtil.isValid(slot)) {
|
||||||
} else {
|
// strg = "Empty";
|
||||||
strg = slot.getDisplayName();
|
// } else {
|
||||||
|
// strg = slot.getDisplayName();
|
||||||
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 29, 1F);
|
//
|
||||||
}
|
// AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 29, 1F);
|
||||||
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, StringUtil.DECIMAL_COLOR_WHITE);
|
// }
|
||||||
}
|
// minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
protected BlockStateContainer createBlockState() {
|
// @Override
|
||||||
return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] { COMPOST_PROP });
|
// protected BlockStateContainer createBlockState() {
|
||||||
}
|
// return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] { COMPOST_PROP });
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
// @Override
|
||||||
TileEntity te = world.getTileEntity(pos);
|
// public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||||
if (te instanceof TileEntityCompost && state instanceof IExtendedBlockState) {
|
// TileEntity te = world.getTileEntity(pos);
|
||||||
TileEntityCompost compost = (TileEntityCompost) te;
|
// if (te instanceof TileEntityCompost && state instanceof IExtendedBlockState) {
|
||||||
return ((IExtendedBlockState) state).withProperty(COMPOST_PROP, Pair.of(compost.getCurrentDisplay(), compost.getHeight()));
|
// TileEntityCompost compost = (TileEntityCompost) te;
|
||||||
}
|
// return ((IExtendedBlockState) state).withProperty(COMPOST_PROP, Pair.of(compost.getCurrentDisplay(), compost.getHeight()));
|
||||||
return state;
|
// }
|
||||||
}
|
// return state;
|
||||||
|
// }
|
||||||
public BlockRenderLayer getBlockLayer() {
|
//
|
||||||
return BlockRenderLayer.CUTOUT;
|
// public BlockRenderLayer getBlockLayer() {
|
||||||
}
|
// return BlockRenderLayer.CUTOUT;
|
||||||
|
// }
|
||||||
public static CompostProperty COMPOST_PROP = new CompostProperty();
|
//
|
||||||
|
// public static CompostProperty COMPOST_PROP = new CompostProperty();
|
||||||
@SuppressWarnings("rawtypes")
|
//
|
||||||
private static class CompostProperty implements IProperty<Pair> {
|
// @SuppressWarnings("rawtypes")
|
||||||
|
// private static class CompostProperty implements IProperty<Pair> {
|
||||||
@Override
|
//
|
||||||
public String getName() {
|
// @Override
|
||||||
return "compost";
|
// public String getName() {
|
||||||
}
|
// return "compost";
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean isValid(Pair value) {
|
// @Override
|
||||||
return true;
|
// public boolean isValid(Pair value) {
|
||||||
}
|
// return true;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public Class<Pair> getType() {
|
// @Override
|
||||||
return Pair.class;
|
// public Class<Pair> getType() {
|
||||||
}
|
// return Pair.class;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public String valueToString(Pair value) {
|
// @Override
|
||||||
return "";
|
// public String valueToString(Pair value) {
|
||||||
}
|
// return "";
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.common.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.common.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.common.tile.TileEntitySmileyCloud;
|
import de.ellpeck.actuallyadditions.common.tile.TileEntitySmileyCloud;
|
||||||
import net.minecraft.block.BlockHorizontal;
|
import net.minecraft.block.BlockHorizontal;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
|
@ -16,6 +17,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -25,7 +27,7 @@ import java.util.Random;
|
||||||
|
|
||||||
public class BlockSmileyCloud extends BlockContainerBase {
|
public class BlockSmileyCloud extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockSmileyCloud(S) {
|
public BlockSmileyCloud() {
|
||||||
super(Properties.create(Material.WOOL)
|
super(Properties.create(Material.WOOL)
|
||||||
.hardnessAndResistance(0.5f, 5.0f)
|
.hardnessAndResistance(0.5f, 5.0f)
|
||||||
.harvestTool(ToolType.PICKAXE)
|
.harvestTool(ToolType.PICKAXE)
|
||||||
|
@ -33,6 +35,11 @@ public class BlockSmileyCloud extends BlockContainerBase {
|
||||||
.tickRandomly());
|
.tickRandomly());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||||
|
return super.isNormalCube(state, worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFullCube(IBlockState state) {
|
public boolean isFullCube(IBlockState state) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,127 +1,127 @@
|
||||||
package de.ellpeck.actuallyadditions.common.blocks;
|
//package de.ellpeck.actuallyadditions.common.blocks;
|
||||||
|
//
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
//import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
||||||
import net.minecraft.block.Block;
|
//import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockHorizontal;
|
//import net.minecraft.block.BlockHorizontal;
|
||||||
import net.minecraft.block.SoundType;
|
//import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
//import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
//import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
//import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
//import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
//import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
//import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Items;
|
//import net.minecraft.init.Items;
|
||||||
import net.minecraft.init.SoundEvents;
|
//import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.item.EnumRarity;
|
//import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.Item;
|
//import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.*;
|
//import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
//import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
//import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
//import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
//import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
//import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
//import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
//
|
||||||
import java.util.Random;
|
//import java.util.Random;
|
||||||
|
//
|
||||||
public class BlockTreasureChest extends Block {
|
//public class BlockTreasureChest extends Block {
|
||||||
|
//
|
||||||
public BlockTreasureChest() {
|
// public BlockTreasureChest() {
|
||||||
super(Block.Properties.create(Material.WOOD)
|
// super(Block.Properties.create(Material.WOOD)
|
||||||
.hardnessAndResistance(300.0f, 50.0f)
|
// .hardnessAndResistance(300.0f, 50.0f)
|
||||||
.harvestTool(ToolType.AXE)
|
// .harvestTool(ToolType.AXE)
|
||||||
.sound(SoundType.WOOD)
|
// .sound(SoundType.WOOD)
|
||||||
.tickRandomly());
|
// .tickRandomly());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
@SideOnly(Side.CLIENT)
|
// @SideOnly(Side.CLIENT)
|
||||||
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
|
// public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
|
||||||
for (int i = 0; i < 2; i++) {
|
// for (int i = 0; i < 2; i++) {
|
||||||
for (float f = 0; f <= 3; f += 0.5) {
|
// for (float f = 0; f <= 3; f += 0.5) {
|
||||||
float particleX = rand.nextFloat();
|
// float particleX = rand.nextFloat();
|
||||||
float particleZ = rand.nextFloat();
|
// float particleZ = rand.nextFloat();
|
||||||
world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double) pos.getX() + particleX, (double) pos.getY() + f + 1, (double) pos.getZ() + particleZ, 0.0D, 0.2D, 0.0D);
|
// world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double) pos.getX() + particleX, (double) pos.getY() + f + 1, (double) pos.getZ() + particleZ, 0.0D, 0.2D, 0.0D);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Item getItemDropped(IBlockState state, Random rand, int par3) {
|
// public Item getItemDropped(IBlockState state, Random rand, int par3) {
|
||||||
return Items.AIR;
|
// return Items.AIR;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
|
// public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
|
||||||
if (!world.isRemote) {
|
// if (!world.isRemote) {
|
||||||
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
|
// world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
this.dropItems(world, pos);
|
// this.dropItems(world, pos);
|
||||||
world.setBlockToAir(pos);
|
// world.setBlockToAir(pos);
|
||||||
|
//
|
||||||
//TheAchievements.OPEN_TREASURE_CHEST.get(player);
|
// //TheAchievements.OPEN_TREASURE_CHEST.get(player);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
// public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
||||||
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
|
// world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
|
||||||
|
//
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
// super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
|
// public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void dropItems(World world, BlockPos pos) {
|
// private void dropItems(World world, BlockPos pos) {
|
||||||
for (int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++) {
|
// for (int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++) {
|
||||||
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
|
// TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
|
||||||
ItemStack itemStack = theReturn.returnItem.copy();
|
// ItemStack itemStack = theReturn.returnItem.copy();
|
||||||
itemStack.setCount(MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount));
|
// itemStack.setCount(MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount));
|
||||||
|
//
|
||||||
float dX = world.rand.nextFloat() * 0.8F + 0.1F;
|
// float dX = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||||
float dY = world.rand.nextFloat() * 0.8F + 0.1F;
|
// float dY = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||||
float dZ = world.rand.nextFloat() * 0.8F + 0.1F;
|
// float dZ = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||||
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack);
|
// EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack);
|
||||||
float factor = 0.05F;
|
// float factor = 0.05F;
|
||||||
entityItem.motionX = world.rand.nextGaussian() * factor;
|
// entityItem.motionX = world.rand.nextGaussian() * factor;
|
||||||
entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F;
|
// entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F;
|
||||||
entityItem.motionZ = world.rand.nextGaussian() * factor;
|
// entityItem.motionZ = world.rand.nextGaussian() * factor;
|
||||||
world.spawnEntity(entityItem);
|
// world.spawnEntity(entityItem);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
// public EnumRarity getRarity(ItemStack stack) {
|
||||||
return EnumRarity.EPIC;
|
// return EnumRarity.EPIC;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
// public IBlockState getStateFromMeta(int meta) {
|
||||||
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
|
// return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int getMetaFromState(IBlockState state) {
|
// public int getMetaFromState(IBlockState state) {
|
||||||
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
|
// return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected BlockStateContainer createBlockState() {
|
// protected BlockStateContainer createBlockState() {
|
||||||
return new BlockStateContainer(this, BlockHorizontal.FACING);
|
// return new BlockStateContainer(this, BlockHorizontal.FACING);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public IBlockState withRotation(IBlockState state, Rotation rot) {
|
// public IBlockState withRotation(IBlockState state, Rotation rot) {
|
||||||
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
|
// return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public IBlockState withMirror(IBlockState state, Mirror mirror) {
|
// public IBlockState withMirror(IBlockState state, Mirror mirror) {
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
|
// return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,87 +1,69 @@
|
||||||
package de.ellpeck.actuallyadditions.common.blocks;
|
package de.ellpeck.actuallyadditions.common.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.common.inventory.GuiHandler;
|
|
||||||
import de.ellpeck.actuallyadditions.common.tile.TileEntityXPSolidifier;
|
import de.ellpeck.actuallyadditions.common.tile.TileEntityXPSolidifier;
|
||||||
import net.minecraft.block.BlockHorizontal;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.state.DirectionProperty;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Mirror;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockXPSolidifier extends BlockContainerBase {
|
public class BlockXPSolidifier extends BlockContainerBase {
|
||||||
|
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
public BlockXPSolidifier() {
|
public BlockXPSolidifier() {
|
||||||
super(Properties.create(Material.ROCK)
|
super(Properties.create(Material.ROCK)
|
||||||
.hardnessAndResistance(2.5f, 10.0f)
|
.hardnessAndResistance(2.5f, 10.0f)
|
||||||
.harvestTool(ToolType.PICKAXE)
|
.harvestTool(ToolType.PICKAXE)
|
||||||
.sound(SoundType.STONE));
|
.sound(SoundType.STONE));
|
||||||
|
|
||||||
|
setDefaultState(getStateContainer().getBaseState().with(FACING, Direction.SOUTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world, int par2) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new TileEntityXPSolidifier();
|
return new TileEntityXPSolidifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier) world.getTileEntity(pos);
|
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier) world.getTileEntity(pos);
|
||||||
if (solidifier != null) {
|
if (solidifier != null) {
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.XP_SOLIDIFIER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
// todo: add back
|
||||||
|
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.XP_SOLIDIFIER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
return super.onBlockActivated(state, world, pos, player, handIn, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
return EnumRarity.EPIC;
|
super.fillStateContainer(builder);
|
||||||
|
builder.add(FACING);
|
||||||
}
|
}
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
|
return getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
|
||||||
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(IBlockState state) {
|
|
||||||
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, BlockHorizontal.FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState withRotation(IBlockState state, Rotation rot) {
|
|
||||||
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState withMirror(IBlockState state, Mirror mirror) {
|
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,8 +206,9 @@ public final class InitBlocks {
|
||||||
public static final RegistryObject<Block> blockCoffee
|
public static final RegistryObject<Block> blockCoffee
|
||||||
= BLOCKS.register("block_coffee", () -> new BlockPlant(2, 2));
|
= BLOCKS.register("block_coffee", () -> new BlockPlant(2, 2));
|
||||||
|
|
||||||
public static final RegistryObject<Block> blockCompost
|
// this isn't needed any more
|
||||||
= BLOCKS.register("block_compost", BlockCompost::new);
|
// public static final RegistryObject<Block> blockCompost
|
||||||
|
// = BLOCKS.register("block_compost", BlockCompost::new);
|
||||||
|
|
||||||
public static final RegistryObject<Block> blockMisc
|
public static final RegistryObject<Block> blockMisc
|
||||||
= BLOCKS.register("block_misc", BlockMisc::new);
|
= BLOCKS.register("block_misc", BlockMisc::new);
|
||||||
|
@ -215,6 +216,7 @@ public final class InitBlocks {
|
||||||
public static final RegistryObject<Block> blockFeeder
|
public static final RegistryObject<Block> blockFeeder
|
||||||
= BLOCKS.register("block_feeder", BlockFeeder::new);
|
= BLOCKS.register("block_feeder", BlockFeeder::new);
|
||||||
|
|
||||||
|
// this isn't needed anymore
|
||||||
// public static final RegistryObject<Block> blockGiantChest
|
// public static final RegistryObject<Block> blockGiantChest
|
||||||
// = BLOCKS.register("block_giant_chest", BlockGiantChest::new);
|
// = BLOCKS.register("block_giant_chest", BlockGiantChest::new);
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue