# Conflicts:
#	src/main/java/techreborn/blocks/BlockAlarm.java
This commit is contained in:
ProfessorProspector 2018-06-14 10:57:07 -07:00
commit 9ed05fb7ff
12 changed files with 171 additions and 142 deletions

View file

@ -1,4 +1,4 @@
![](http://i.imgur.com/XKMokQu.png "Tech Reborn")
![](https://i.imgur.com/evHOtQl.png "Tech Reborn")
[![](http://cf.way2muchnoise.eu/full_233564_downloads.svg)](https://minecraft.curseforge.com/projects/techreborn) [![](http://cf.way2muchnoise.eu/versions/233564.svg)](https://minecraft.curseforge.com/projects/techreborn) [![](https://img.shields.io/badge/Discord-TeamReborn-738bd7.svg)](https://discord.gg/teamreborn)

View file

@ -45,8 +45,10 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.api.ToolManager;
import reborncore.common.BaseTileBlock;
import techreborn.utils.TechRebornCreativeTab;
import reborncore.common.items.WrenchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileAlarm;
@ -88,18 +90,29 @@ public class BlockAlarm extends BaseTileBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileAlarm tileEntity = (TileAlarm) worldIn.getTileEntity(pos);
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
// We extended BaseTileBlock. Thus we should always have tile entity. I hope.
if (tileEntity == null) {
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
} else {
if (!worldIn.isRemote) {
if (playerIn.isSneaking()) {
tileEntity.rightClick();
}
return false;
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchHelper.handleWrench(stack, worldIn, pos, playerIn, side)) {
return true;
}
}
return true;
if (!worldIn.isRemote && playerIn.isSneaking()) {
((TileAlarm) tileEntity).rightClick();
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override
@ -167,10 +180,10 @@ public class BlockAlarm extends BaseTileBlock {
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return this.bbs[getFacing(state).getIndex()];
}
@Override
public void addInformation(final ItemStack stack, final World world, final List<String> tooltip, ITooltipFlag flag) {
tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.tooltip.alarm"));

View file

@ -34,11 +34,14 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.common.RebornCoreConfig;
import reborncore.common.blocks.PropertyString;
import reborncore.common.multiblock.BlockMultiblockBase;
import reborncore.common.util.ArrayUtils;
@ -80,6 +83,33 @@ public class BlockMachineCasing extends BlockMultiblockBase {
public static ItemStack getStackByName(String name) {
return getStackByName(name, 1);
}
/**
* Provides heat info per casing for Industrial Blast Furnace
* @param state Machine casing type
* @return Integer Heat value for casing
*/
public int getHeatFromState(IBlockState state) {
switch (getMetaFromState(state)) {
case 0:
return 1020 / 25;
case 1:
return 1700 / 25;
case 2:
return 2380 / 25;
}
return 0;
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
if (RebornCoreConfig.wrenchRequired){
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
}
else {
super.getDrops(drops, world, pos, state, fortune);
}
}
@Override
public IBlockState getStateFromMeta(int meta) {
@ -99,23 +129,6 @@ public class BlockMachineCasing extends BlockMultiblockBase {
return new BlockStateContainer(this, TYPE);
}
/**
* Provides heat info per casing for Industrial Blast Furnace
* @param state Machine casing type
* @return Integer Heat value for casing
*/
public int getHeatFromState(IBlockState state) {
switch (getMetaFromState(state)) {
case 0:
return 1020 / 25;
case 1:
return 1700 / 25;
case 2:
return 2380 / 25;
}
return 0;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Item.getItemFromBlock(this);

View file

@ -77,7 +77,39 @@ public class BlockLamp extends BaseTileBlock {
this.brightness = brightness;
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/lighting"));
}
public static boolean isActive(IBlockState state) {
return state.getValue(ACTIVE);
}
public static EnumFacing getFacing(IBlockState state) {
if(!state.getProperties().containsKey(FACING)){
return EnumFacing.NORTH;
}
return state.getValue(FACING);
}
public static void setFacing(EnumFacing facing, World world, BlockPos pos) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
}
public static void setActive(Boolean active, World world, BlockPos pos) {
EnumFacing facing = (EnumFacing)world.getBlockState(pos).getValue(FACING);
IBlockState state = world.getBlockState(pos).withProperty(ACTIVE, active).withProperty(FACING, facing);
world.setBlockState(pos, state, 3);
}
public int getCost() {
return cost;
}
// BaseTileBlock
@Override
public TileEntity createNewTileEntity(final World world, final int meta) {
return new TileLamp();
}
// Block
@Override
protected BlockStateContainer createBlockState() {
FACING = PropertyDirection.create("facing");
@ -85,11 +117,6 @@ public class BlockLamp extends BaseTileBlock {
return new BlockStateContainer(this, FACING, ACTIVE);
}
@Override
public TileEntity createNewTileEntity(final World world, final int meta) {
return new TileLamp();
}
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
@ -148,29 +175,4 @@ public class BlockLamp extends BaseTileBlock {
EnumFacing facing = EnumFacing.getFront(meta&7);
return this.getDefaultState().withProperty(FACING, facing).withProperty(ACTIVE, active);
}
public static boolean isActive(IBlockState state) {
return state.getValue(ACTIVE);
}
public static EnumFacing getFacing(IBlockState state) {
if(!state.getProperties().containsKey(FACING)){
return EnumFacing.NORTH;
}
return state.getValue(FACING);
}
public static void setFacing(EnumFacing facing, World world, BlockPos pos) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
}
public static void setActive(Boolean active, World world, BlockPos pos) {
EnumFacing facing = (EnumFacing)world.getBlockState(pos).getValue(FACING);
IBlockState state = world.getBlockState(pos).withProperty(ACTIVE, active).withProperty(FACING, facing);
world.setBlockState(pos, state, 3);
}
public int getCost() {
return cost;
}
}

View file

@ -24,17 +24,18 @@
package techreborn.blocks.tier2;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.api.tile.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.WorldUtils;
import techreborn.client.EGui;
import techreborn.utils.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
@ -66,18 +67,12 @@ public class BlockDigitalChest extends BlockMachineBase {
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
/* if (RebornCoreConfig.wrenchRequired){
drops.add(isAdvanced() ? advancedFrameStack.copy() : basicFrameStack.copy());
}
else {
super.getDrops(drops, world, pos, state, fortune);
}*/
TileEntity storageTile = world.getTileEntity(pos);
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntity storageTile = worldIn.getTileEntity(pos);
if (storageTile != null && storageTile instanceof TileTechStorageBase) {
drops.addAll( ( (TileTechStorageBase) storageTile).getContentDrops() );
List<ItemStack> stacks = ((TileTechStorageBase) storageTile).getContentDrops();
WorldUtils.dropItems(stacks, worldIn, pos);
}
super.getDrops(drops, world, pos, state, fortune);
super.breakBlock(worldIn, pos, state);
}
}

View file

@ -24,18 +24,18 @@
package techreborn.blocks.tier3;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.api.tile.IMachineGuiHandler;
import reborncore.common.RebornCoreConfig;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.WorldUtils;
import techreborn.client.EGui;
import techreborn.utils.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
@ -67,18 +67,12 @@ public class BlockQuantumChest extends BlockMachineBase {
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
/* if (RebornCoreConfig.wrenchRequired){
drops.add(isAdvanced() ? advancedFrameStack.copy() : basicFrameStack.copy());
}
else {
super.getDrops(drops, world, pos, state, fortune);
}*/
TileEntity storageTile = world.getTileEntity(pos);
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntity storageTile = worldIn.getTileEntity(pos);
if (storageTile != null && storageTile instanceof TileTechStorageBase) {
drops.addAll(((TileTechStorageBase) storageTile).getContentDrops());
List<ItemStack> stacks = ((TileTechStorageBase) storageTile).getContentDrops();
WorldUtils.dropItems(stacks, worldIn, pos);
}
super.getDrops(drops, world, pos, state, fortune);
super.breakBlock(worldIn, pos, state);
}
}

View file

@ -27,6 +27,7 @@ package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -34,9 +35,6 @@ import reborncore.common.RebornCoreConfig;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileHVTransformer;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -50,17 +48,14 @@ public class BlockHVTransformer extends BlockTransformer {
public TileEntity createNewTileEntity(final World world, final int meta) {
return new TileHVTransformer();
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
List<ItemStack> items = new ArrayList<ItemStack>();
public void getDrops(NonNullList<ItemStack> drops, final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
if (RebornCoreConfig.wrenchRequired){
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
}
else {
items.add(new ItemStack(this));
drops.add(new ItemStack(this));
}
return items;
}
}

View file

@ -27,6 +27,7 @@ package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -34,9 +35,6 @@ import reborncore.common.RebornCoreConfig;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileMVTransformer;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -52,16 +50,12 @@ public class BlockMVTransformer extends BlockTransformer {
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
List<ItemStack> items = new ArrayList<ItemStack>();
public void getDrops(NonNullList<ItemStack> drops, final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
if (RebornCoreConfig.wrenchRequired){
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
}
else {
items.add(new ItemStack(this));
drops.add(new ItemStack(this));
}
return items;
}
}

View file

@ -232,5 +232,4 @@ public abstract class BlockTransformer extends BaseTileBlock {
return Iterators.forArray(this.facings());
}
}
}

View file

@ -26,6 +26,8 @@ package techreborn.tiles;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
@ -34,14 +36,52 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.util.ChatUtils;
import techreborn.blocks.BlockAlarm;
import techreborn.init.ModBlocks;
import techreborn.init.ModSounds;
import techreborn.lib.MessageIDs;
public class TileAlarm extends TileEntity implements ITickable {
public class TileAlarm extends TileEntity
implements ITickable, IToolDrop {
private int selectedSound = 1;
public void rightClick() {
if (!world.isRemote) {
if (selectedSound < 3) {
selectedSound++;
} else {
selectedSound = 1;
}
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.alarm") + " " + "Alarm " + selectedSound));
}
}
// TileEntity
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
if (compound == null) {
compound = new NBTTagCompound();
}
compound.setInteger("selectedSound", this.selectedSound);
return super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
if (compound != null && compound.hasKey("selectedSound")) {
this.selectedSound = compound.getInteger("selectedSound");
}
super.readFromNBT(compound);
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
return false;
}
// ITickable
@Override
public void update() {
if (!world.isRemote && world.getTotalWorldTime() % 25 == 0 && world.isBlockPowered(getPos())) {
@ -63,36 +103,9 @@ public class TileAlarm extends TileEntity implements ITickable {
}
}
// IToolDrop
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
if (compound == null) {
compound = new NBTTagCompound();
}
compound.setInteger("selectedSound", this.selectedSound);
return super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
if (compound != null && compound.hasKey("selectedSound")) {
this.selectedSound = compound.getInteger("selectedSound");
}
super.readFromNBT(compound);
}
public void rightClick() {
if (!world.isRemote) {
if (selectedSound < 3) {
selectedSound++;
} else {
selectedSound = 1;
}
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.alarm") + " " + "Alarm " + selectedSound));
}
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
return false;
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.ALARM, 1);
}
}

View file

@ -115,8 +115,9 @@ public class TileTechStorageBase extends TileLegacyMachineBase
ArrayList<ItemStack> stacks = new ArrayList<>();
if (!this.getStoredItemType().isEmpty()) {
if (!this.getStackInSlot(1).isEmpty())
if (!this.getStackInSlot(1).isEmpty()) {
stacks.add(this.getStackInSlot(1));
}
for (int i = 0; i < this.getStoredCount() / 64; i++) {
ItemStack droped = this.storedItem.copy();
droped.setCount(64);

View file

@ -26,16 +26,20 @@ package techreborn.tiles.lighting;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.TilePowerAcceptor;
import techreborn.blocks.lighting.BlockLamp;
import techreborn.init.ModBlocks;
public class TileLamp extends TilePowerAcceptor
implements ITickable {
public class TileLamp extends TilePowerAcceptor
implements IToolDrop {
private static int capacity = 33;
// TilePowerAcceptor
@Override
public void update() {
super.update();
@ -81,5 +85,11 @@ public class TileLamp extends TilePowerAcceptor
return 32;
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.LAMP_LED, 1);
}
}