mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Merge remote-tracking branch 'origin/mc1.17/dev' into mc1.18/dev
This commit is contained in:
commit
5d435e1da7
7 changed files with 41 additions and 26 deletions
|
@ -224,12 +224,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<Entry<Entity, MutableInt>> iterator = collidingEntities.entrySet()
|
collidingEntities.entrySet().removeIf(e -> e.getValue().incrementAndGet() > 3);
|
||||||
.iterator(); iterator.hasNext();)
|
|
||||||
if (iterator.next()
|
|
||||||
.getValue()
|
|
||||||
.incrementAndGet() > 3)
|
|
||||||
iterator.remove();
|
|
||||||
|
|
||||||
xo = getX();
|
xo = getX();
|
||||||
yo = getY();
|
yo = getY();
|
||||||
|
|
|
@ -74,17 +74,12 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
public float prevPitch;
|
public float prevPitch;
|
||||||
public float pitch;
|
public float pitch;
|
||||||
public float targetPitch;
|
|
||||||
|
|
||||||
// When placed using a contraption item
|
|
||||||
private float initialYawOffset;
|
|
||||||
|
|
||||||
public OrientedContraptionEntity(EntityType<?> type, Level world) {
|
public OrientedContraptionEntity(EntityType<?> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
motionBeforeStall = Vec3.ZERO;
|
motionBeforeStall = Vec3.ZERO;
|
||||||
attachedExtraInventories = false;
|
attachedExtraInventories = false;
|
||||||
isSerializingFurnaceCart = false;
|
isSerializingFurnaceCart = false;
|
||||||
initialYawOffset = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OrientedContraptionEntity create(Level world, Contraption contraption, Direction initialOrientation) {
|
public static OrientedContraptionEntity create(Level world, Contraption contraption, Direction initialOrientation) {
|
||||||
|
@ -112,11 +107,6 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
return entityData.get(INITIAL_ORIENTATION);
|
return entityData.get(INITIAL_ORIENTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deferOrientation(Direction newInitialAngle) {
|
|
||||||
entityData.set(INITIAL_ORIENTATION, Direction.UP);
|
|
||||||
yaw = initialYawOffset = newInitialAngle.toYRot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getYawOffset() {
|
public float getYawOffset() {
|
||||||
return getInitialYaw();
|
return getInitialYaw();
|
||||||
|
@ -398,7 +388,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
prevYaw = yaw;
|
prevYaw = yaw;
|
||||||
float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXsize() / 6f)));
|
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);
|
approach = Mth.clamp(approach, -maxApproachSpeed, maxApproachSpeed);
|
||||||
yaw += approach;
|
yaw += approach;
|
||||||
if (Math.abs(AngleHelper.getShortestAngleDiff(yaw, targetYaw)) < 1f)
|
if (Math.abs(AngleHelper.getShortestAngleDiff(yaw, targetYaw)) < 1f)
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
package com.simibubi.create.content.curiosities.toolbox;
|
package com.simibubi.create.content.curiosities.toolbox;
|
||||||
|
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||||
|
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For inserting items into a players' inventory anywhere except the hotbar
|
* 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);
|
super(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
import com.simibubi.create.AllEntityTypes;
|
import com.simibubi.create.AllEntityTypes;
|
||||||
|
@ -113,9 +115,15 @@ public class BlueprintEntity extends HangingEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag p_70037_1_) {
|
public void readAdditionalSaveData(CompoundTag p_70037_1_) {
|
||||||
|
if (p_70037_1_.contains("Facing", Tag.TAG_ANY_NUMERIC)) {
|
||||||
this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing"));
|
this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing"));
|
||||||
this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation"));
|
this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation"));
|
||||||
this.size = p_70037_1_.getInt("Size");
|
this.size = p_70037_1_.getInt("Size");
|
||||||
|
} else {
|
||||||
|
this.direction = Direction.SOUTH;
|
||||||
|
this.verticalOrientation = Direction.DOWN;
|
||||||
|
this.size = 1;
|
||||||
|
}
|
||||||
super.readAdditionalSaveData(p_70037_1_);
|
super.readAdditionalSaveData(p_70037_1_);
|
||||||
this.updateFacingWithBoundingBox(this.direction, this.verticalOrientation);
|
this.updateFacingWithBoundingBox(this.direction, this.verticalOrientation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
ChuteTileEntity targetChute = getTargetChute(blockState);
|
ChuteTileEntity targetChute = getTargetChute(blockState);
|
||||||
Direction direction = AbstractChuteBlock.getChuteFacing(blockState);
|
Direction direction = AbstractChuteBlock.getChuteFacing(blockState);
|
||||||
|
|
||||||
if (level == null)
|
if (level == null || direction == null || !this.canOutputItems())
|
||||||
return false;
|
return false;
|
||||||
if (!capBelow.isPresent())
|
if (!capBelow.isPresent())
|
||||||
capBelow = grabCapability(Direction.DOWN);
|
capBelow = grabCapability(Direction.DOWN);
|
||||||
|
@ -404,7 +404,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
private boolean handleUpwardOutput(boolean simulate) {
|
private boolean handleUpwardOutput(boolean simulate) {
|
||||||
BlockState stateAbove = level.getBlockState(worldPosition.above());
|
BlockState stateAbove = level.getBlockState(worldPosition.above());
|
||||||
|
|
||||||
if (level == null)
|
if (level == null || !this.canOutputItems())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AbstractChuteBlock.isOpenChute(getBlockState())) {
|
if (AbstractChuteBlock.isOpenChute(getBlockState())) {
|
||||||
|
@ -477,6 +477,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean canOutputItems() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private LazyOptional<IItemHandler> grabCapability(Direction side) {
|
private LazyOptional<IItemHandler> grabCapability(Direction side) {
|
||||||
BlockPos pos = this.worldPosition.relative(side);
|
BlockPos pos = this.worldPosition.relative(side);
|
||||||
if (level == null)
|
if (level == null)
|
||||||
|
|
|
@ -42,6 +42,12 @@ public class SmartChuteTileEntity extends ChuteTileEntity {
|
||||||
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
|
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
|
@Override
|
||||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||||
behaviours.add(filtering =
|
behaviours.add(filtering =
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
|
||||||
public class AngleHelper {
|
public class AngleHelper {
|
||||||
|
|
||||||
|
@ -40,4 +41,12 @@ public class AngleHelper {
|
||||||
return (float) (((((target - current) % 360) + 540) % 360) - 180);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue