This commit is contained in:
modmuss50 2019-06-04 12:05:18 +01:00
parent e8396dbc33
commit d18d1b820e
65 changed files with 287 additions and 520 deletions

View file

@ -41,6 +41,7 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
@ -130,7 +131,7 @@ public class BlockAlarm extends BaseTileBlock {
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -140,7 +141,7 @@ public class BlockAlarm extends BaseTileBlock {
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return true;
}
}
@ -151,7 +152,7 @@ public class BlockAlarm extends BaseTileBlock {
}
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
@Override

View file

@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@ -56,11 +57,11 @@ public class BlockComputerCube extends BlockMachineBase {
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND);
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) {
if (ToolManager.INSTANCE.handleTool(tool, pos, worldIn, playerIn, side, false)) {
if (ToolManager.INSTANCE.handleTool(tool, pos, worldIn, playerIn, hitResult.getSide(), false)) {
if (playerIn.isSneaking()) {
ItemStack drop = new ItemStack(TRContent.COMPUTER_CUBE, 1);
dropStack(worldIn, pos, drop);
@ -72,7 +73,7 @@ public class BlockComputerCube extends BlockMachineBase {
return true;
}
else {
rotate(worldIn.getBlockState(pos), worldIn, pos, BlockRotation.CLOCKWISE_90);
rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
return true;
}
}

View file

@ -24,6 +24,7 @@
package techreborn.blocks;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.GlassBlock;
@ -38,12 +39,8 @@ import java.util.Random;
public class BlockReinforcedGlass extends GlassBlock {
public BlockReinforcedGlass() {
super(Block.Settings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE));
super(FabricBlockSettings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE).build());
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this));
}
@Override
public int quantityDropped(BlockState state, Random random) {
return 1;
}
}

View file

@ -24,6 +24,7 @@
package techreborn.blocks;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -42,7 +43,7 @@ import techreborn.init.TRContent;
public class BlockRubberLeaves extends LeavesBlock {
public BlockRubberLeaves() {
super(Block.Settings.of(Material.LEAVES).strength(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS));
super(FabricBlockSettings.of(Material.LEAVES).hardness(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS).build());
((FireBlock) Blocks.FIRE).registerFlammableBlock(this, 30, 60);
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, EnvTypeANCE, PERSISTENT));
}

View file

@ -44,6 +44,7 @@ import net.minecraft.tag.BlockTags;
import net.minecraft.tag.Tag;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@ -92,7 +93,7 @@ public class BlockRubberLog extends LogBlock {
int i = 4;
int j = i + 1;
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) {
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i))) {
for (BlockPos blockpos : BlockPos.iterate(pos.add(-i, -i, -i), pos.add(i, i, i))) {
BlockState state1 = worldIn.getBlockState(blockpos);
if (state1.matches(BlockTags.LEAVES)) {
state1.scheduledTick(worldIn, blockpos, worldIn.getRandom());
@ -123,9 +124,9 @@ public class BlockRubberLog extends LogBlock {
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, Direction side, float hitX, float hitY, float hitZ) {
super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, BlockHitResult hitResult) {
super.activate(state, worldIn, pos, playerIn, hand, hitResult);
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
if (stack.isEmpty()) {
return false;
@ -135,7 +136,7 @@ public class BlockRubberLog extends LogBlock {
capEnergy = new ItemPowerManager(stack);
}
if ((capEnergy != null && capEnergy.getEnergyStored() > 20) || stack.getItem() instanceof ItemTreeTap) {
if (state.get(HAS_SAP) && state.get(SAP_SIDE) == side) {
if (state.get(HAS_SAP) && state.get(SAP_SIDE) == hitResult.getSide()) {
worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0)));
worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS,
0.6F, 1F);
@ -148,7 +149,7 @@ public class BlockRubberLog extends LogBlock {
playerIn.getStackInHand(Hand.MAIN_HAND).damageItem(1, playerIn);
}
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(side));
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
}
if (playerIn instanceof ServerPlayerEntity) {
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);

View file

@ -36,6 +36,7 @@ import net.minecraft.state.StateFactory;
import net.minecraft.state.property.AbstractProperty;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
@ -126,7 +127,7 @@ public class BlockCable extends BlockWithEntity {
// Block
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -136,11 +137,11 @@ public class BlockCable extends BlockWithEntity {
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return true;
}
}
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
@Override

View file

@ -36,6 +36,7 @@ import net.minecraft.network.chat.TextComponent;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
@ -59,8 +60,8 @@ public class BlockFusionCoil extends Block {
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, BlockHitResult hitResult) {
ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND);
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) {

View file

@ -29,6 +29,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
@ -54,8 +55,8 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, BlockHitResult hitResult) {
final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getBlockEntity(pos);
if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){
List<BlockPos> coils = Torus.generate(tileFusionControlComputer.getPos(), tileFusionControlComputer.size);
@ -78,7 +79,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
tileFusionControlComputer.checkCoils();
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
@Override

View file

@ -40,6 +40,7 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
@ -142,29 +143,10 @@ public class BlockLamp extends BaseTileBlock {
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override
public boolean isFullCube(BlockState state) {
return false;
}
@Override
public BlockFaceShape getBlockFaceShape(BlockView worldIn, BlockState state, BlockPos pos, Direction facing) {
// This makes only the back face of lamps connect to fences.
if (getFacing(state).getOpposite() == facing)
return BlockFaceShape.SOLID;
else
return BlockFaceShape.UNDEFINED;
}
@Override
public VoxelShape getShape(BlockState state, BlockView worldIn, BlockPos pos) {
return shape[getFacing(state).getId()];
}
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -174,11 +156,11 @@ public class BlockLamp extends BaseTileBlock {
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return true;
}
}
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
}

View file

@ -35,6 +35,7 @@ import net.minecraft.state.StateFactory;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@ -102,7 +103,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -112,7 +113,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return true;
}
}
@ -122,7 +123,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
return true;
}
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
@Override

View file

@ -33,6 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
@ -93,7 +94,7 @@ public class BlockLSUStorage extends BaseTileBlock {
// Block
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -103,12 +104,12 @@ public class BlockLSUStorage extends BaseTileBlock {
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return true;
}
}
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
@Override

View file

@ -38,6 +38,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.state.StateFactory;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
@ -90,12 +91,12 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
if (tileEntity == null) {
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
String type = state.get(TYPE);
@ -103,7 +104,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
ChatFormat color = ChatFormat.GREEN;
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, side, false)) {
if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, hitResult.getSide(), false)) {
if (playerIn.isSneaking()) {
if (tileEntity instanceof IToolDrop) {
ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(playerIn);

View file

@ -34,9 +34,9 @@ import techreborn.TechReborn;
import techreborn.client.EGui;
import techreborn.tiles.machine.multiblock.TileEnvTypeillationTower;
public class BlockEnvTypeillationTower extends BlockMachineBase {
public class BlockDistillationTower extends BlockMachineBase {
public BlockEnvTypeillationTower() {
public BlockDistillationTower() {
super();
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/tier2_machines"));
}

View file

@ -35,6 +35,7 @@ import net.minecraft.state.StateFactory;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@ -92,7 +93,7 @@ public abstract class BlockTransformer extends BaseTileBlock {
@SuppressWarnings("deprecation")
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -102,11 +103,11 @@ public abstract class BlockTransformer extends BaseTileBlock {
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return true;
}
}
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
}
}