Merge remote-tracking branch 'remotes/origin/1.14' into 1.15
# Conflicts: # build.gradle # src/main/java/techreborn/blocks/misc/BlockRubberLog.java
This commit is contained in:
commit
d5e89c5e20
139 changed files with 1534 additions and 501 deletions
|
@ -39,10 +39,12 @@ import net.minecraft.state.property.AbstractProperty;
|
|||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -57,11 +59,15 @@ import techreborn.init.TRContent;
|
|||
import techreborn.utils.damageSources.ElectrialShockSource;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 19/05/2017.
|
||||
*/
|
||||
public class BlockCable extends BlockWithEntity {
|
||||
public class CableBlock extends BlockWithEntity {
|
||||
|
||||
public static final BooleanProperty EAST = BooleanProperty.of("east");
|
||||
public static final BooleanProperty WEST = BooleanProperty.of("west");
|
||||
|
@ -70,9 +76,18 @@ public class BlockCable extends BlockWithEntity {
|
|||
public static final BooleanProperty UP = BooleanProperty.of("up");
|
||||
public static final BooleanProperty DOWN = BooleanProperty.of("down");
|
||||
|
||||
public static final Map<Direction, BooleanProperty> PROPERTY_MAP = SystemUtil.consume(new HashMap<>(), map -> {
|
||||
map.put(Direction.EAST, EAST);
|
||||
map.put(Direction.WEST, WEST);
|
||||
map.put(Direction.NORTH, NORTH);
|
||||
map.put(Direction.SOUTH, SOUTH);
|
||||
map.put(Direction.UP, UP);
|
||||
map.put(Direction.DOWN, DOWN);
|
||||
});
|
||||
|
||||
public final TRContent.Cables type;
|
||||
|
||||
public BlockCable(TRContent.Cables type) {
|
||||
public CableBlock(TRContent.Cables type) {
|
||||
super(Block.Settings.of(Material.STONE).strength(1f, 8f));
|
||||
this.type = type;
|
||||
setDefaultState(this.stateFactory.getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false)
|
||||
|
@ -128,7 +143,7 @@ public class BlockCable extends BlockWithEntity {
|
|||
@Nullable
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView worldIn) {
|
||||
return new CableBlockEntity();
|
||||
return new CableBlockEntity(type);
|
||||
}
|
||||
|
||||
// Block
|
||||
|
@ -169,13 +184,21 @@ public class BlockCable extends BlockWithEntity {
|
|||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, EntityContext entityContext) {
|
||||
if (type != null) {
|
||||
// outline is 1px bigger then model to ease selection
|
||||
double culling = type.cableThickness - 1;
|
||||
return Block.createCuboidShape(culling, culling, culling, 16.0D - culling, 16.0D - culling,
|
||||
16.0D - culling);
|
||||
double size = type != null ? type.cableThickness : 6;
|
||||
VoxelShape baseShape = Block.createCuboidShape(size, size, size, 16.0D - size, 16.0D - size, 16.0D - size);
|
||||
|
||||
List<VoxelShape> connections = new ArrayList<>();
|
||||
for(Direction dir : Direction.values()){
|
||||
if(state.get(PROPERTY_MAP.get(dir))) {
|
||||
double x = dir == Direction.WEST ? 0 : dir == Direction.EAST ? 16D : size;
|
||||
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
|
||||
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;
|
||||
|
||||
VoxelShape shape = Block.createCuboidShape(x, y, z, 16.0D - size, 16.0D - size, 16.0D - size);
|
||||
connections.add(shape);
|
||||
}
|
||||
}
|
||||
return Block.createCuboidShape(4, 4, 4, 12, 12, 12);
|
||||
return VoxelShapes.union(baseShape, connections.toArray(new VoxelShape[]{}));
|
||||
}
|
||||
|
||||
@Override
|
|
@ -45,7 +45,7 @@ public class BlockSolarPanel extends BlockMachineBase {
|
|||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView worldIn) {
|
||||
return new SolarPanelBlockEntity();
|
||||
return new SolarPanelBlockEntity(panelType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.blocks.lighting;
|
|||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -61,25 +62,29 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
|||
|
||||
public BlockLamp(int cost, double depth, double width) {
|
||||
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness).build());
|
||||
this.shape = GenCuboidShapes(depth, width);
|
||||
this.shape = genCuboidShapes(depth, width);
|
||||
this.cost = cost;
|
||||
this.setDefaultState(this.stateFactory.getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
}
|
||||
|
||||
private VoxelShape[] GenCuboidShapes(double depth, double width) {
|
||||
private VoxelShape[] genCuboidShapes(double depth, double width) {
|
||||
double culling = (16.0D - width) / 2 ;
|
||||
VoxelShape[] shapes = {
|
||||
Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||
Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||
Block.createCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
|
||||
Block.createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||
Block.createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||
Block.createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||
return new VoxelShape[]{
|
||||
createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||
createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||
createCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
|
||||
createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||
createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||
createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||
};
|
||||
return shapes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
|
||||
return shape[blockState.get(FACING).ordinal()];
|
||||
}
|
||||
|
||||
public static boolean isActive(BlockState state) {
|
||||
return state.get(ACTIVE);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ package techreborn.blocks.misc;
|
|||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
@ -44,7 +46,6 @@ import net.minecraft.util.hit.BlockHitResult;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import team.reborn.energy.Energy;
|
||||
import techreborn.events.TRRecipeHandler;
|
||||
|
@ -120,24 +121,36 @@ public class BlockRubberLog extends LogBlock {
|
|||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof AxeItem) {
|
||||
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (worldIn.isClient) {
|
||||
return true;
|
||||
}
|
||||
worldIn.setBlockState(pos, TRContent.RUBBER_LOG_STRIPPED.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11);
|
||||
if (playerIn instanceof LivingEntity) {
|
||||
LivingEntity playerEntity = (LivingEntity) playerIn;
|
||||
stack.damage(1, playerEntity, player -> { player.sendToolBreakStatus(hand); });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((Energy.valid(stack) && Energy.of(stack).getEnergy() > 20) || stack.getItem() instanceof ItemTreeTap) {
|
||||
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);
|
||||
if (!worldIn.isClient) {
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(stack).use(20);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, playerIn);
|
||||
} else {
|
||||
playerIn.getStackInHand(Hand.MAIN_HAND).damage(1, playerIn, playerEntity -> {});
|
||||
}
|
||||
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
|
||||
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
|
||||
}
|
||||
if (playerIn instanceof ServerPlayerEntity) {
|
||||
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);
|
||||
}
|
||||
worldIn.playSound(playerIn, pos, ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
if (worldIn.isClient) {
|
||||
return true;
|
||||
}
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(stack).use(20);
|
||||
} else {
|
||||
stack.damage(1, playerIn, player -> { player.sendToolBreakStatus(hand); });
|
||||
}
|
||||
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
|
||||
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
|
||||
}
|
||||
if (playerIn instanceof ServerPlayerEntity) {
|
||||
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue