Merge branch 'master' into mc1.15/dev
This commit is contained in:
commit
c501de8c21
6 changed files with 89 additions and 30 deletions
|
@ -26,6 +26,7 @@ import com.simibubi.create.modules.logistics.block.transposer.TransposerBlock;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractPressurePlateBlock;
|
import net.minecraft.block.AbstractPressurePlateBlock;
|
||||||
import net.minecraft.block.AbstractRailBlock;
|
import net.minecraft.block.AbstractRailBlock;
|
||||||
|
import net.minecraft.block.BellBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
@ -33,6 +34,7 @@ import net.minecraft.block.CarpetBlock;
|
||||||
import net.minecraft.block.DoorBlock;
|
import net.minecraft.block.DoorBlock;
|
||||||
import net.minecraft.block.FenceGateBlock;
|
import net.minecraft.block.FenceGateBlock;
|
||||||
import net.minecraft.block.FlowerPotBlock;
|
import net.minecraft.block.FlowerPotBlock;
|
||||||
|
import net.minecraft.block.HorizontalBlock;
|
||||||
import net.minecraft.block.HorizontalFaceBlock;
|
import net.minecraft.block.HorizontalFaceBlock;
|
||||||
import net.minecraft.block.LadderBlock;
|
import net.minecraft.block.LadderBlock;
|
||||||
import net.minecraft.block.RedstoneDiodeBlock;
|
import net.minecraft.block.RedstoneDiodeBlock;
|
||||||
|
@ -42,6 +44,7 @@ import net.minecraft.block.TorchBlock;
|
||||||
import net.minecraft.block.WallTorchBlock;
|
import net.minecraft.block.WallTorchBlock;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.state.properties.AttachFace;
|
import net.minecraft.state.properties.AttachFace;
|
||||||
|
import net.minecraft.state.properties.BellAttachment;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -145,6 +148,8 @@ public class BlockMovementTraits {
|
||||||
return true;
|
return true;
|
||||||
if (block instanceof CarpetBlock)
|
if (block instanceof CarpetBlock)
|
||||||
return true;
|
return true;
|
||||||
|
if (block instanceof BellBlock)
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +203,16 @@ public class BlockMovementTraits {
|
||||||
return direction == state.get(NozzleBlock.FACING).getOpposite();
|
return direction == state.get(NozzleBlock.FACING).getOpposite();
|
||||||
if (block instanceof EngineBlock)
|
if (block instanceof EngineBlock)
|
||||||
return direction == state.get(EngineBlock.HORIZONTAL_FACING).getOpposite();
|
return direction == state.get(EngineBlock.HORIZONTAL_FACING).getOpposite();
|
||||||
|
if (block instanceof BellBlock) {
|
||||||
|
BellAttachment attachment = state.get(BlockStateProperties.BELL_ATTACHMENT);
|
||||||
|
if (attachment == BellAttachment.FLOOR) {
|
||||||
|
return direction == Direction.DOWN;
|
||||||
|
}
|
||||||
|
if (attachment == BellAttachment.CEILING) {
|
||||||
|
return direction == Direction.UP;
|
||||||
|
}
|
||||||
|
return direction == state.get(HorizontalBlock.HORIZONTAL_FACING);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simibubi.create.modules.contraptions.components.contraptions.chassis.
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
|
||||||
|
|
||||||
|
import net.minecraft.block.BellBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.HorizontalFaceBlock;
|
import net.minecraft.block.HorizontalFaceBlock;
|
||||||
|
@ -20,6 +21,8 @@ import net.minecraft.block.SlabBlock;
|
||||||
import net.minecraft.block.StairsBlock;
|
import net.minecraft.block.StairsBlock;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.properties.AttachFace;
|
import net.minecraft.state.properties.AttachFace;
|
||||||
|
import net.minecraft.state.properties.BellAttachment;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.state.properties.Half;
|
import net.minecraft.state.properties.Half;
|
||||||
import net.minecraft.state.properties.SlabType;
|
import net.minecraft.state.properties.SlabType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -79,11 +82,18 @@ public class StructureTransform {
|
||||||
* horizontal axes
|
* horizontal axes
|
||||||
*/
|
*/
|
||||||
public BlockState apply(BlockState state) {
|
public BlockState apply(BlockState state) {
|
||||||
if (rotationAxis == Axis.Y)
|
|
||||||
return state.rotate(rotation);
|
|
||||||
|
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
|
if (rotationAxis == Axis.Y) {
|
||||||
|
if (block instanceof BellBlock) {
|
||||||
|
if (state.get(BlockStateProperties.BELL_ATTACHMENT) == BellAttachment.DOUBLE_WALL) {
|
||||||
|
state = state.with(BlockStateProperties.BELL_ATTACHMENT, BellAttachment.SINGLE_WALL);
|
||||||
|
}
|
||||||
|
return state.with(HorizontalFaceBlock.HORIZONTAL_FACING, rotation.rotate(state.get(HorizontalFaceBlock.HORIZONTAL_FACING)));
|
||||||
|
}
|
||||||
|
return state.rotate(rotation);
|
||||||
|
}
|
||||||
|
|
||||||
if (block instanceof AbstractChassisBlock)
|
if (block instanceof AbstractChassisBlock)
|
||||||
return rotateChassis(state);
|
return rotateChassis(state);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.AllEntities;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.AllPackets;
|
import com.simibubi.create.AllPackets;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.contraptions.BlockMovementTraits;
|
||||||
import com.simibubi.create.modules.schematics.ISpecialEntityItemRequirement;
|
import com.simibubi.create.modules.schematics.ISpecialEntityItemRequirement;
|
||||||
import com.simibubi.create.modules.schematics.ItemRequirement;
|
import com.simibubi.create.modules.schematics.ItemRequirement;
|
||||||
import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType;
|
import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType;
|
||||||
|
@ -154,11 +155,20 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
|
||||||
BlockPos pos2 = hangingPosition.offset(getFacingDirection().getOpposite());
|
BlockPos pos2 = hangingPosition.offset(getFacingDirection().getOpposite());
|
||||||
if (!world.isAreaLoaded(pos, 0) || !world.isAreaLoaded(pos2, 0))
|
if (!world.isAreaLoaded(pos, 0) || !world.isAreaLoaded(pos2, 0))
|
||||||
return true;
|
return true;
|
||||||
if (world.isAirBlock(pos) && world.isAirBlock(pos2))
|
if (!isValidFace(world, pos2, getFacingDirection()) && !isValidFace(world, pos, getFacingDirection().getOpposite()))
|
||||||
return false;
|
return false;
|
||||||
return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity).isEmpty();
|
return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidFace(World world, BlockPos pos, Direction direction) {
|
||||||
|
if (!BlockMovementTraits.movementNecessary(world, pos))
|
||||||
|
return false;
|
||||||
|
if (BlockMovementTraits.notSupportive(world.getBlockState(pos), direction)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeCollidedWith() {
|
public boolean canBeCollidedWith() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
|
||||||
return false;
|
return false;
|
||||||
BlockPos pos = entity.hangingPosition;
|
BlockPos pos = entity.hangingPosition;
|
||||||
BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite());
|
BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite());
|
||||||
return entity.world.isAirBlock(pos) != entity.world.isAirBlock(pos2);
|
return !SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) || !SuperGlueEntity.isValidFace(entity.world, pos, entity.getFacingDirection().getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initQuads() {
|
private void initQuads() {
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class DeployerFakePlayer extends FakePlayer {
|
||||||
return new StringTextComponent(Lang.translate("block.deployer.damage_source_name"));
|
return new StringTextComponent(Lang.translate("block.deployer.damage_source_name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public float getEyeHeight(Pose poseIn) {
|
public float getEyeHeight(Pose poseIn) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.deployer;
|
package com.simibubi.create.modules.contraptions.components.deployer;
|
||||||
|
|
||||||
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
|
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
|
||||||
|
import static net.minecraftforge.eventbus.api.Event.Result.DEFAULT;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -47,7 +48,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
|
||||||
import net.minecraftforge.eventbus.api.Event.Result;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
public class DeployerHandler {
|
public class DeployerHandler {
|
||||||
|
|
||||||
|
@ -72,8 +73,10 @@ public class DeployerHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlockState(BlockPos position) {
|
public BlockState getBlockState(BlockPos position) {
|
||||||
if (rayMode && (pos.offset(face.getOpposite(), 3).equals(position)
|
if (rayMode && (pos.offset(face.getOpposite(), 3)
|
||||||
|| pos.offset(face.getOpposite(), 1).equals(position)))
|
.equals(position)
|
||||||
|
|| pos.offset(face.getOpposite(), 1)
|
||||||
|
.equals(position)))
|
||||||
return Blocks.BEDROCK.getDefaultState();
|
return Blocks.BEDROCK.getDefaultState();
|
||||||
return world.getBlockState(position);
|
return world.getBlockState(position);
|
||||||
}
|
}
|
||||||
|
@ -81,13 +84,16 @@ public class DeployerHandler {
|
||||||
|
|
||||||
static boolean shouldActivate(ItemStack held, World world, BlockPos targetPos) {
|
static boolean shouldActivate(ItemStack held, World world, BlockPos targetPos) {
|
||||||
if (held.getItem() instanceof BlockItem)
|
if (held.getItem() instanceof BlockItem)
|
||||||
if (!world.getBlockState(targetPos).getMaterial().isReplaceable())
|
if (!world.getBlockState(targetPos)
|
||||||
|
.getMaterial()
|
||||||
|
.isReplaceable())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (held.getItem() instanceof BucketItem) {
|
if (held.getItem() instanceof BucketItem) {
|
||||||
BucketItem bucketItem = (BucketItem) held.getItem();
|
BucketItem bucketItem = (BucketItem) held.getItem();
|
||||||
Fluid fluid = bucketItem.getFluid();
|
Fluid fluid = bucketItem.getFluid();
|
||||||
if (fluid != Fluids.EMPTY && world.getFluidState(targetPos).getFluid() == fluid)
|
if (fluid != Fluids.EMPTY && world.getFluidState(targetPos)
|
||||||
|
.getFluid() == fluid)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,15 +101,17 @@ public class DeployerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void activate(DeployerFakePlayer player, Vec3d vec, BlockPos clickedPos, Vec3d extensionVector, Mode mode) {
|
static void activate(DeployerFakePlayer player, Vec3d vec, BlockPos clickedPos, Vec3d extensionVector, Mode mode) {
|
||||||
Multimap<String, AttributeModifier> attributeModifiers =
|
Multimap<String, AttributeModifier> attributeModifiers = player.getHeldItemMainhand()
|
||||||
player.getHeldItemMainhand().getAttributeModifiers(EquipmentSlotType.MAINHAND);
|
.getAttributeModifiers(EquipmentSlotType.MAINHAND);
|
||||||
player.getAttributes().applyAttributeModifiers(attributeModifiers);
|
player.getAttributes()
|
||||||
|
.applyAttributeModifiers(attributeModifiers);
|
||||||
activateInner(player, vec, clickedPos, extensionVector, mode);
|
activateInner(player, vec, clickedPos, extensionVector, mode);
|
||||||
player.getAttributes().removeAttributeModifiers(attributeModifiers);
|
player.getAttributes()
|
||||||
|
.removeAttributeModifiers(attributeModifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void activateInner(DeployerFakePlayer player, Vec3d vec, BlockPos clickedPos, Vec3d extensionVector,
|
private static void activateInner(DeployerFakePlayer player, Vec3d vec, BlockPos clickedPos, Vec3d extensionVector,
|
||||||
Mode mode) {
|
Mode mode) {
|
||||||
|
|
||||||
Vec3d rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f));
|
Vec3d rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f));
|
||||||
Vec3d rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f));
|
Vec3d rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f));
|
||||||
|
@ -133,7 +141,7 @@ public class DeployerHandler {
|
||||||
if (entity.processInitialInteract(player, hand))
|
if (entity.processInitialInteract(player, hand))
|
||||||
success = true;
|
success = true;
|
||||||
else if (entity instanceof LivingEntity
|
else if (entity instanceof LivingEntity
|
||||||
&& stack.interactWithEntity(player, (LivingEntity) entity, hand))
|
&& stack.interactWithEntity(player, (LivingEntity) entity, hand))
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,22 +168,24 @@ public class DeployerHandler {
|
||||||
BlockState clickedState = world.getBlockState(clickedPos);
|
BlockState clickedState = world.getBlockState(clickedPos);
|
||||||
Direction face = result.getFace();
|
Direction face = result.getFace();
|
||||||
if (face == null)
|
if (face == null)
|
||||||
face = Direction.getFacingFromVector(extensionVector.x, extensionVector.y, extensionVector.z).getOpposite();
|
face = Direction.getFacingFromVector(extensionVector.x, extensionVector.y, extensionVector.z)
|
||||||
|
.getOpposite();
|
||||||
|
|
||||||
// Left click
|
// Left click
|
||||||
if (mode == Mode.PUNCH) {
|
if (mode == Mode.PUNCH) {
|
||||||
LeftClickBlock event = ForgeHooks.onLeftClickBlock(player, clickedPos, face);
|
|
||||||
if (event.isCanceled())
|
|
||||||
return;
|
|
||||||
if (!world.isBlockModifiable(player, clickedPos))
|
if (!world.isBlockModifiable(player, clickedPos))
|
||||||
return;
|
return;
|
||||||
if (world.extinguishFire(player, clickedPos, face))
|
if (clickedState.getRenderShape(world, clickedPos)
|
||||||
return;
|
.isEmpty()) {
|
||||||
if (clickedState.isAir(world, clickedPos)) {
|
|
||||||
player.blockBreakingProgress = null;
|
player.blockBreakingProgress = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getUseBlock() != Result.DENY)
|
LeftClickBlock event = ForgeHooks.onLeftClickBlock(player, clickedPos, face);
|
||||||
|
if (event.isCanceled())
|
||||||
|
return;
|
||||||
|
if (world.extinguishFire(player, clickedPos, face))
|
||||||
|
return;
|
||||||
|
if (event.getUseBlock() != DENY)
|
||||||
clickedState.onBlockClicked(world, clickedPos, player);
|
clickedState.onBlockClicked(world, clickedPos, player);
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -193,6 +203,10 @@ public class DeployerHandler {
|
||||||
player.blockBreakingProgress = null;
|
player.blockBreakingProgress = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (progress <= 0) {
|
||||||
|
player.blockBreakingProgress = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((int) (before * 10) != (int) (progress * 10))
|
if ((int) (before * 10) != (int) (progress * 10))
|
||||||
world.sendBlockBreakProgress(player.getEntityId(), clickedPos, (int) (progress * 10));
|
world.sendBlockBreakProgress(player.getEntityId(), clickedPos, (int) (progress * 10));
|
||||||
|
@ -202,25 +216,33 @@ public class DeployerHandler {
|
||||||
|
|
||||||
// Right click
|
// Right click
|
||||||
ItemUseContext itemusecontext = new ItemUseContext(player, hand, result);
|
ItemUseContext itemusecontext = new ItemUseContext(player, hand, result);
|
||||||
RightClickBlock event = ForgeHooks.onRightClickBlock(player, hand, clickedPos, face);
|
Event.Result useBlock = DENY;
|
||||||
|
Event.Result useItem = DEFAULT;
|
||||||
|
if (!clickedState.getRenderShape(world, clickedPos)
|
||||||
|
.isEmpty()) {
|
||||||
|
RightClickBlock event = ForgeHooks.onRightClickBlock(player, hand, clickedPos, face);
|
||||||
|
useBlock = event.getUseBlock();
|
||||||
|
useItem = event.getUseItem();
|
||||||
|
}
|
||||||
|
|
||||||
// Item has custom active use
|
// Item has custom active use
|
||||||
if (event.getUseItem() != DENY) {
|
if (useItem != DENY) {
|
||||||
ActionResultType actionresult = stack.onItemUseFirst(itemusecontext);
|
ActionResultType actionresult = stack.onItemUseFirst(itemusecontext);
|
||||||
if (actionresult != ActionResultType.PASS)
|
if (actionresult != ActionResultType.PASS)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean holdingSomething = !player.getHeldItemMainhand().isEmpty();
|
boolean holdingSomething = !player.getHeldItemMainhand()
|
||||||
|
.isEmpty();
|
||||||
boolean flag1 =
|
boolean flag1 =
|
||||||
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
||||||
|
|
||||||
// Use on block
|
// Use on block
|
||||||
if (event.getUseBlock() != DENY && flag1 && clickedState.onUse(world, player, hand, result) == ActionResultType.SUCCESS)
|
if (useBlock != DENY && flag1 && clickedState.onUse(world, player, hand, result) == ActionResultType.SUCCESS)
|
||||||
return;
|
return;
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (event.getUseItem() == DENY)
|
if (useItem == DENY)
|
||||||
return;
|
return;
|
||||||
if (item instanceof BlockItem && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext)))
|
if (item instanceof BlockItem && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext)))
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +280,8 @@ public class DeployerHandler {
|
||||||
if (stack.isFood())
|
if (stack.isFood())
|
||||||
player.spawnedItemEffects = stack.copy();
|
player.spawnedItemEffects = stack.copy();
|
||||||
|
|
||||||
if (!player.getActiveItemStack().isEmpty())
|
if (!player.getActiveItemStack()
|
||||||
|
.isEmpty())
|
||||||
player.setHeldItem(hand, stack.onItemUseFinish(world, player));
|
player.setHeldItem(hand, stack.onItemUseFinish(world, player));
|
||||||
|
|
||||||
player.resetActiveHand();
|
player.resetActiveHand();
|
||||||
|
|
Loading…
Reference in a new issue