This commit is contained in:
Modmuss50 2015-11-23 19:51:40 +00:00
parent ef82ceb714
commit 839647ed85
9 changed files with 86 additions and 99 deletions

View file

@ -2,10 +2,13 @@ package techreborn.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -42,7 +45,7 @@ public class BlockMachineCasing extends BlockMultiblockBase {
}
@Override
public Item getItemDropped(int meta, Random random, int fortune) {
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Item.getItemFromBlock(this);
}
@ -55,8 +58,8 @@ public class BlockMachineCasing extends BlockMultiblockBase {
}
@Override
public int damageDropped(int metaData) {
return metaData;
public int damageDropped(IBlockState state) {
return super.damageDropped(state);
}
@Override
@ -64,11 +67,10 @@ public class BlockMachineCasing extends BlockMultiblockBase {
return new TileMachineCasing();
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
Block b = par1IBlockAccess.getBlock(par2, par3, par4);
return b == (Block) this ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
Block b = worldIn.getBlockState(pos).getBlock();
return b == (Block) this ? false : super.shouldSideBeRendered(worldIn, pos, side);
}
public boolean shouldConnectToBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta) {

View file

@ -2,6 +2,7 @@ package techreborn.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -43,9 +44,9 @@ public class BlockMachineFrame extends Block {
}
}
@Override
public int damageDropped(int metaData) {
return metaData;
}
@Override
public int damageDropped(IBlockState state) {
return super.damageDropped(state);
}
}

View file

@ -2,12 +2,15 @@ package techreborn.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -21,6 +24,7 @@ import techreborn.items.ItemGems;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BlockOre extends Block {
@ -52,14 +56,18 @@ public class BlockOre extends Block {
setHardness(2.0f);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
@Deprecated
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
int metadata = 0; //TODO meta fix
Random random = new Random();
//Ruby
if (metadata == 2) {
OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby"), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
OreDrop redGarnet = new OreDrop(ItemGems.getGemByName("redGarnet"), 0.02);
OreDropSet set = new OreDropSet(ruby, redGarnet);
return set.drop(fortune, world.rand);
return set.drop(fortune, random);
}
//Sapphire
@ -67,14 +75,14 @@ public class BlockOre extends Block {
OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire"), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
OreDrop peridot = new OreDrop(ItemGems.getGemByName("peridot"), 0.03);
OreDropSet set = new OreDropSet(sapphire, peridot);
return set.drop(fortune, world.rand);
return set.drop(fortune, random);
}
//Pyrite
if (metadata == 5) {
OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite"), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
OreDropSet set = new OreDropSet(pyriteDust);
return set.drop(fortune, world.rand);
return set.drop(fortune, random);
}
//Sodolite
@ -82,7 +90,7 @@ public class BlockOre extends Block {
OreDrop sodalite = new OreDrop(ItemDusts.getDustByName("sodalite", 6), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
OreDrop aluminum = new OreDrop(ItemDusts.getDustByName("aluminum"), 0.50);
OreDropSet set = new OreDropSet(sodalite, aluminum);
return set.drop(fortune, world.rand);
return set.drop(fortune, random);
}
//Cinnabar
@ -90,7 +98,7 @@ public class BlockOre extends Block {
OreDrop cinnabar = new OreDrop(ItemDusts.getDustByName("cinnabar"), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
OreDrop redstone = new OreDrop(new ItemStack(Items.redstone), 0.25);
OreDropSet set = new OreDropSet(cinnabar, redstone);
return set.drop(fortune, world.rand);
return set.drop(fortune, random);
}
//Sphalerite 1, 1/8 yellow garnet
@ -98,7 +106,7 @@ public class BlockOre extends Block {
OreDrop sphalerite = new OreDrop(ItemDusts.getDustByName("sphalerite"), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel);
OreDrop yellowGarnet = new OreDrop(ItemGems.getGemByName("yellowGarnet"), 0.125);
OreDropSet set = new OreDropSet(sphalerite, yellowGarnet);
return set.drop(fortune, world.rand);
return set.drop(fortune, random);
}
ArrayList<ItemStack> block = new ArrayList<ItemStack>();
@ -119,21 +127,22 @@ public class BlockOre extends Block {
}
}
@Override
public int damageDropped(int metaData) {
if (metaData == 2) {
return 0;
} else if (metaData == 3) {
return 1;
} else if (metaData == 5) {
return 60;
}
return metaData;
}
// @Override
// public int damageDropped(int metaData) {
// if (metaData == 2) {
// return 0;
// } else if (metaData == 3) {
// return 1;
// } else if (metaData == 5) {
// return 60;
// }
// return metaData;
// }
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return new ItemStack(ModBlocks.ore, 1, world.getBlockMetadata(x, y, z));
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
return super.getPickBlock(target, world, pos, player);
}
}

View file

@ -2,14 +2,17 @@ package techreborn.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -34,7 +37,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
@Override
public Item getItemDropped(int par1, Random random, int par2) {
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Item.getItemFromBlock(this);
}
@ -46,10 +49,6 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
}
@Override
public int damageDropped(int metaData) {
return metaData;
}
@Override
@ -63,7 +62,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) {
return true;
}
@ -73,8 +72,8 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
@Override
public int isProvidingStrongPower(IBlockAccess blockAccess, int x, int y, int z, int side) {
TileEntity entity = blockAccess.getTileEntity(x, y, z);
public int isProvidingWeakPower(IBlockAccess blockAccess, BlockPos pos, IBlockState state, EnumFacing side) {
TileEntity entity = blockAccess.getTileEntity(pos);
if (entity instanceof TilePlayerDectector) {
return ((TilePlayerDectector) entity).isProvidingPower() ? 15 : 0;
}
@ -82,8 +81,8 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
@Override
public int isProvidingWeakPower(IBlockAccess blockAccess, int x, int y, int z, int side) {
TileEntity entity = blockAccess.getTileEntity(x, y, z);
public int isProvidingStrongPower(IBlockAccess blockAccess, BlockPos pos, IBlockState state, EnumFacing side) {
TileEntity entity = blockAccess.getTileEntity(pos);
if (entity instanceof TilePlayerDectector) {
return ((TilePlayerDectector) entity).isProvidingPower() ? 15 : 0;
}
@ -93,7 +92,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
super.onBlockPlacedBy(world, x, y, z, player, itemstack);
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if (tile instanceof TilePlayerDectector) {
((TilePlayerDectector) tile).owenerUdid = player.getUniqueID().toString();
}
@ -104,7 +103,8 @@ public class BlockPlayerDetector extends BlockMachineBase {
if (super.onBlockActivated(world, x, y, z, entityplayer, side, hitX, hitY, hitZ)) {
return true;
}
int newMeta = (world.getBlockMetadata(x, y, z) + 1) % 3;
// int newMeta = (world.getBlockMetadata(x, y, z) + 1) % 3;
int newMeta = 0; //TODO meta fix
String message = "";
switch (newMeta) {
case 0:
@ -118,7 +118,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
if(!world.isRemote){
entityplayer.addChatComponentMessage(new ChatComponentText(message));
world.setBlockMetadataWithNotify(x, y, z, newMeta, 2);
//world.setBlockMetadataWithNotify(x, y, z, newMeta, 2);
}
return true;
}

View file

@ -1,12 +1,11 @@
package techreborn.blocks.storage;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -18,42 +17,12 @@ import techreborn.tiles.idsu.TileIDSU;
public class BlockIDSU extends BlockMachineBase {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockIDSU(Material material) {
super(material);
setUnlocalizedName("techreborn.idsu");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon("techreborn:machine/idsu_side");
this.iconFront = icon.registerIcon("techreborn:machine/idsu_front");
this.iconTop = icon.registerIcon("techreborn:machine/idsu_side");
this.iconBottom = icon.registerIcon("techreborn:machine/idsu_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
int metadata = getTileRotation(blockAccess, x, y, z);
if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) {
return this.iconFront;
}
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop :
side == 0 ? this.iconBottom : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileIDSU(5, 2048, 100000000);
@ -72,7 +41,7 @@ public class BlockIDSU extends BlockMachineBase {
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
super.onBlockPlacedBy(world, x, y, z, player, itemstack);
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if (tile instanceof TileIDSU) {
((TileIDSU) tile).ownerUdid = player.getUniqueID().toString();
}

View file

@ -5,6 +5,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.blocks.BlockMachineBase;
@ -21,15 +22,15 @@ public class BlockLesuStorage extends BlockMachineBase {
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
super.onBlockPlacedBy(world, x, y, z, player, itemstack);
if (world.getTileEntity(x, y, z) instanceof TileLesuStorage) {
((TileLesuStorage) world.getTileEntity(x, y, z)).rebuildNetwork();
if (world.getTileEntity(new BlockPos(x, y, z)) instanceof TileLesuStorage) {
((TileLesuStorage) world.getTileEntity(new BlockPos(x, y, z))).rebuildNetwork();
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (world.getTileEntity(x, y, z) instanceof TileLesuStorage) {
((TileLesuStorage) world.getTileEntity(x, y, z)).removeFromNetwork();
if (world.getTileEntity(new BlockPos(x, y, z)) instanceof TileLesuStorage) {
((TileLesuStorage) world.getTileEntity(new BlockPos(x, y, z))).removeFromNetwork();
}
super.breakBlock(world, x, y, z, block, meta);
}

View file

@ -15,7 +15,7 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable {
public static final int MAX_OUTPUT = ConfigTechReborn.aesuMaxOutput;
public static final int MAX_STORAGE = ConfigTechReborn.aesuMaxStorage;
public Inventory inventory = new Inventory(2, "TileAesu", 64);
public Inventory inventory = new Inventory(2, "TileAesu", 64, this);
private int OUTPUT = 64; //The current output
private double euLastTick = 0;
private double euChange;
@ -116,7 +116,7 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable {
ItemStack dropStack = new ItemStack(ModBlocks.Aesu, 1);
writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound());
dropStack.stackTagCompound.setTag("tileEntity", tileEntity);
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
return dropStack;
}

View file

@ -53,24 +53,25 @@ public class TilePlayerDectector extends TilePowerAcceptor {
while (tIterator.hasNext()) {
EntityPlayer player = (EntityPlayer) tIterator.next();
if (player.getDistanceSq((double) super.getPos().getX() + 0.5D, (double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D) {
if(worldObj.getBlockMetadata(getPos().getX(), getPos().getY(), getPos().getZ()) == 0){//ALL
redstone = true;
} else if (blockMetadata == 1){//Others
if(!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString())){
redstone = true;
}
} else {//You
if(!owenerUdid.isEmpty() &&owenerUdid.equals(player.getUniqueID().toString())){
redstone = true;
}
}
// if(worldObj.getBlockMetadata(getPos().getX(), getPos().getY(), getPos().getZ()) == 0){//ALL
// redstone = true;
// } else if (blockMetadata == 1){//Others
// if(!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString())){
// redstone = true;
// }
// } else {//You
// if(!owenerUdid.isEmpty() &&owenerUdid.equals(player.getUniqueID().toString())){
// redstone = true;
// }
// }//TODO meta fix
redstone = true;
}
}
useEnergy(50);
}
if(lastRedstone != redstone){
worldObj.markBlockForUpdate(getPos().getX(), getPos().getY(), getPos().getZ());
worldObj.notifyBlocksOfNeighborChange(getPos().getX(), getPos().getY(), getPos().getZ(), worldObj.getBlock(getPos().getX(), getPos().getY(), getPos().getZ()));
worldObj.markBlockForUpdate(getPos());
worldObj.notifyNeighborsOfStateChange(getPos(), worldObj.getBlockState(getPos()).getBlock());
}
}
}

View file

@ -45,14 +45,18 @@ public class TileIDSU extends TilePowerAcceptor {
return 1000000000;
}
//TODO meta fix
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return worldObj.getBlockMetadata(getPos().getX(), getPos().getY(), getPos().getZ()) != Functions.getIntDirFromDirection(direction);
//return worldObj.getBlockMetadata(getPos().getX(), getPos().getY(), getPos().getZ()) != Functions.getIntDirFromDirection(direction);
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return worldObj.getBlockMetadata(getPos().getX(), getPos().getY(), getPos().getZ()) == Functions.getIntDirFromDirection(direction);
//return worldObj.getBlockMetadata(getPos().getX(), getPos().getY(), getPos().getZ()) == Functions.getIntDirFromDirection(direction);
return true;
}
@Override