Merge remote-tracking branch 'origin/mc1.17/dev' into mc1.18/dev

This commit is contained in:
reidbhuntley 2021-12-22 22:19:17 -05:00
commit 5d435e1da7
7 changed files with 41 additions and 26 deletions

View file

@ -224,12 +224,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return;
}
for (Iterator<Entry<Entity, MutableInt>> iterator = collidingEntities.entrySet()
.iterator(); iterator.hasNext();)
if (iterator.next()
.getValue()
.incrementAndGet() > 3)
iterator.remove();
collidingEntities.entrySet().removeIf(e -> e.getValue().incrementAndGet() > 3);
xo = getX();
yo = getY();
@ -642,7 +637,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public boolean hasExactlyOnePlayerPassenger() {
return false;
}
@OnlyIn(Dist.CLIENT)
public abstract void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks);

View file

@ -74,17 +74,12 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
public float prevPitch;
public float pitch;
public float targetPitch;
// When placed using a contraption item
private float initialYawOffset;
public OrientedContraptionEntity(EntityType<?> type, Level world) {
super(type, world);
motionBeforeStall = Vec3.ZERO;
attachedExtraInventories = false;
isSerializingFurnaceCart = false;
initialYawOffset = -1;
}
public static OrientedContraptionEntity create(Level world, Contraption contraption, Direction initialOrientation) {
@ -112,11 +107,6 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
return entityData.get(INITIAL_ORIENTATION);
}
public void deferOrientation(Direction newInitialAngle) {
entityData.set(INITIAL_ORIENTATION, Direction.UP);
yaw = initialYawOffset = newInitialAngle.toYRot();
}
@Override
public float getYawOffset() {
return getInitialYaw();
@ -398,7 +388,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
prevYaw = yaw;
float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXsize() / 6f)));
float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw);
float yawHint = AngleHelper.getShortestAngleDiff(yaw, yawFromVector(locationDiff));
float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw, yawHint);
approach = Mth.clamp(approach, -maxApproachSpeed, maxApproachSpeed);
yaw += approach;
if (Math.abs(AngleHelper.getShortestAngleDiff(yaw, targetYaw)) < 1f)

View file

@ -1,15 +1,17 @@
package com.simibubi.create.content.curiosities.toolbox;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
/**
* For inserting items into a players' inventory anywhere except the hotbar
*/
public class ItemReturnInvWrapper extends InvWrapper {
public class ItemReturnInvWrapper extends PlayerMainInvWrapper {
public ItemReturnInvWrapper(Container inv) {
public ItemReturnInvWrapper(Inventory inv) {
super(inv);
}

View file

@ -7,6 +7,8 @@ import java.util.Optional;
import javax.annotation.Nullable;
import net.minecraft.nbt.Tag;
import org.apache.commons.lang3.Validate;
import com.simibubi.create.AllEntityTypes;
@ -113,9 +115,15 @@ public class BlueprintEntity extends HangingEntity
@Override
public void readAdditionalSaveData(CompoundTag p_70037_1_) {
this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing"));
this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation"));
this.size = p_70037_1_.getInt("Size");
if (p_70037_1_.contains("Facing", Tag.TAG_ANY_NUMERIC)) {
this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing"));
this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation"));
this.size = p_70037_1_.getInt("Size");
} else {
this.direction = Direction.SOUTH;
this.verticalOrientation = Direction.DOWN;
this.size = 1;
}
super.readAdditionalSaveData(p_70037_1_);
this.updateFacingWithBoundingBox(this.direction, this.verticalOrientation);
}

View file

@ -153,7 +153,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
}
float nextOffset = itemPosition.value + itemMotion;
if (itemMotion < 0) {
if (nextOffset < .5f) {
if (!handleDownwardOutput(true))
@ -352,7 +352,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
ChuteTileEntity targetChute = getTargetChute(blockState);
Direction direction = AbstractChuteBlock.getChuteFacing(blockState);
if (level == null)
if (level == null || direction == null || !this.canOutputItems())
return false;
if (!capBelow.isPresent())
capBelow = grabCapability(Direction.DOWN);
@ -404,7 +404,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
private boolean handleUpwardOutput(boolean simulate) {
BlockState stateAbove = level.getBlockState(worldPosition.above());
if (level == null)
if (level == null || !this.canOutputItems())
return false;
if (AbstractChuteBlock.isOpenChute(getBlockState())) {
@ -477,6 +477,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
return true;
}
protected boolean canOutputItems() {
return true;
}
private LazyOptional<IItemHandler> grabCapability(Direction side) {
BlockPos pos = this.worldPosition.relative(side);
if (level == null)

View file

@ -41,6 +41,12 @@ public class SmartChuteTileEntity extends ChuteTileEntity {
BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
}
@Override
protected boolean canOutputItems() {
BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {

View file

@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.util.Mth;
public class AngleHelper {
@ -40,4 +41,12 @@ public class AngleHelper {
return (float) (((((target - current) % 360) + 540) % 360) - 180);
}
public static float getShortestAngleDiff(double current, double target, float hint) {
float diff = getShortestAngleDiff(current, target);
if (Mth.equal(Math.abs(diff), 180) && Math.signum(diff) != Math.signum(hint)) {
return diff + 360*Math.signum(hint);
}
return diff;
}
}