mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
Pocket Carts
- Minecarts with mounted contraptions can now be picked up as an item - Furnace Minecarts can now be used in the cart assembler - Fixed superglue not re-appearing when moved in piston contraptions - Fixed deployer not being able to interact with non-living entities - Fixed Schematic deploy tool outline not rendering at the right location for certain boundary sizes - Fixed leaking GL texture parameters from outline rendering - Added Italian localization - Fixed file extension of Japanese localization
This commit is contained in:
parent
885791f878
commit
75638b7c8d
18 changed files with 1558 additions and 38 deletions
|
@ -17,6 +17,7 @@ import com.simibubi.create.modules.IModule;
|
|||
import com.simibubi.create.modules.contraptions.GogglesItem;
|
||||
import com.simibubi.create.modules.contraptions.WrenchItem;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.glue.SuperGlueItem;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.mounted.MinecartContraptionItem;
|
||||
import com.simibubi.create.modules.contraptions.relays.belt.item.BeltConnectorItem;
|
||||
import com.simibubi.create.modules.contraptions.relays.gearbox.VerticalGearboxItem;
|
||||
import com.simibubi.create.modules.curiosities.ChromaticCompoundCubeItem;
|
||||
|
@ -39,6 +40,7 @@ import com.simibubi.create.modules.schematics.item.SchematicItem;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity.Type;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.Properties;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -99,6 +101,8 @@ public enum AllItems {
|
|||
RED_SAND_PAPER(SandPaperItem::new),
|
||||
WRENCH(WrenchItem::new),
|
||||
GOGGLES(GogglesItem::new),
|
||||
MINECART_CONTRAPTION(p -> new MinecartContraptionItem(Type.RIDEABLE, p)),
|
||||
FURNACE_MINECART_CONTRAPTION(p -> new MinecartContraptionItem(Type.FURNACE, p)),
|
||||
|
||||
__LOGISTICS__(module()),
|
||||
FILTER(FilterItem::new),
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.foundation.utility;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -20,4 +22,14 @@ public class GlHelper {
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void enableTextureRepeat() {
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10242, GL11.GL_REPEAT);
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10243, GL11.GL_REPEAT);
|
||||
}
|
||||
|
||||
public static void disableTextureRepeat() {
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10242, GL11.GL_CLAMP);
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10243, GL11.GL_CLAMP);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package com.simibubi.create.foundation.utility.outliner;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.simibubi.create.AllSpecialTextures;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.GlHelper;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
|
@ -99,9 +98,6 @@ public class AABBOutline extends Outline {
|
|||
}
|
||||
|
||||
protected void renderFace(Direction direction, Vec3d p1, Vec3d p2, Vec3d p3, Vec3d p4, BufferBuilder buffer) {
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10242, GL11.GL_REPEAT);
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10243, GL11.GL_REPEAT);
|
||||
|
||||
if (direction == highlightedFace && highlightedTexture != null)
|
||||
highlightedTexture.bind();
|
||||
else if (faceTexture != null)
|
||||
|
@ -109,16 +105,18 @@ public class AABBOutline extends Outline {
|
|||
else
|
||||
return;
|
||||
|
||||
GlStateManager.depthMask(false);
|
||||
Vec3d uDiff = p2.subtract(p1);
|
||||
Vec3d vDiff = p4.subtract(p1);
|
||||
Axis axis = direction.getAxis();
|
||||
float maxU = (float) Math.abs(axis == Axis.X ? uDiff.z : uDiff.x);
|
||||
float maxV = (float) Math.abs(axis == Axis.Y ? vDiff.z : vDiff.y);
|
||||
|
||||
GlHelper.enableTextureRepeat();
|
||||
GlStateManager.depthMask(false);
|
||||
putQuadUV(p1, p2, p3, p4, 0, 0, maxU, maxV, new Vec3d(1, 1, 1), 1, buffer);
|
||||
flush();
|
||||
GlStateManager.depthMask(true);
|
||||
GlHelper.disableTextureRepeat();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public abstract class Contraption {
|
|||
protected BlockPos anchor;
|
||||
|
||||
List<BlockPos> renderOrder;
|
||||
List<SuperGlueEntity> glueToRemove;
|
||||
protected List<SuperGlueEntity> glueToRemove;
|
||||
|
||||
public Contraption() {
|
||||
blocks = new HashMap<>();
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.apache.commons.lang3.tuple.MutablePair;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.simibubi.create.AllEntities;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.bearing.BearingContraption;
|
||||
|
@ -19,12 +20,17 @@ import com.simibubi.create.modules.contraptions.components.contraptions.mounted.
|
|||
import com.simibubi.create.modules.contraptions.components.contraptions.mounted.MountedContraption;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.piston.LinearActuatorTileEntity;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.item.BoatEntity;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
|
@ -33,11 +39,14 @@ import net.minecraft.network.PacketBuffer;
|
|||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ReuseableStream;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
|
@ -56,12 +65,14 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
|
||||
protected Contraption contraption;
|
||||
protected float initialAngle;
|
||||
protected float forcedAngle;
|
||||
protected BlockPos controllerPos;
|
||||
protected Vec3d motionBeforeStall;
|
||||
protected boolean stationary;
|
||||
|
||||
final List<Entity> collidingEntities = new ArrayList<>();
|
||||
|
||||
private static final Ingredient FUEL_ITEMS = Ingredient.fromItems(Items.COAL, Items.CHARCOAL);
|
||||
private static final DataParameter<Boolean> STALLED =
|
||||
EntityDataManager.createKey(ContraptionEntity.class, DataSerializers.BOOLEAN);
|
||||
|
||||
|
@ -81,19 +92,25 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
super(entityTypeIn, worldIn);
|
||||
motionBeforeStall = Vec3d.ZERO;
|
||||
stationary = entityTypeIn == AllEntities.STATIONARY_CONTRAPTION.type;
|
||||
forcedAngle = -1;
|
||||
}
|
||||
|
||||
public static ContraptionEntity createMounted(World world, Contraption contraption, float initialAngle) {
|
||||
ContraptionEntity entity = new ContraptionEntity(AllEntities.CONTRAPTION.type, world);
|
||||
entity.contraption = contraption;
|
||||
entity.initialAngle = initialAngle;
|
||||
entity.prevYaw = initialAngle;
|
||||
entity.yaw = initialAngle;
|
||||
entity.targetYaw = initialAngle;
|
||||
entity.forceYaw(initialAngle);
|
||||
if (contraption != null)
|
||||
contraption.gatherStoredItems();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static ContraptionEntity createMounted(World world, Contraption contraption, float initialAngle, Direction facing) {
|
||||
ContraptionEntity entity = createMounted(world, contraption, initialAngle);
|
||||
entity.forcedAngle = facing.getHorizontalAngle();
|
||||
entity.forceYaw(entity.forcedAngle);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static ContraptionEntity createStationary(World world, Contraption contraption) {
|
||||
ContraptionEntity entity = new ContraptionEntity(AllEntities.STATIONARY_CONTRAPTION.type, world);
|
||||
|
@ -207,6 +224,39 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
motionBeforeStall = Vec3d.ZERO;
|
||||
}
|
||||
|
||||
if (!isStalled() && (riding instanceof FurnaceMinecartEntity)) {
|
||||
FurnaceMinecartEntity furnaceCart = (FurnaceMinecartEntity) riding;
|
||||
CompoundNBT nbt = furnaceCart.serializeNBT();
|
||||
int fuel = nbt.getInt("Fuel");
|
||||
int fuelBefore = fuel;
|
||||
double pushX = nbt.getDouble("PushX");
|
||||
double pushZ = nbt.getDouble("PushZ");
|
||||
|
||||
int i = MathHelper.floor(furnaceCart.posX);
|
||||
int j = MathHelper.floor(furnaceCart.posY);
|
||||
int k = MathHelper.floor(furnaceCart.posZ);
|
||||
if (furnaceCart.world.getBlockState(new BlockPos(i, j - 1, k)).isIn(BlockTags.RAILS))
|
||||
--j;
|
||||
|
||||
BlockPos blockpos = new BlockPos(i, j, k);
|
||||
BlockState blockstate = this.world.getBlockState(blockpos);
|
||||
if (furnaceCart.canUseRail() && blockstate.isIn(BlockTags.RAILS))
|
||||
if (fuel > 1)
|
||||
riding.setMotion(riding.getMotion().normalize().scale(1));
|
||||
if (fuel < 5 && contraption != null) {
|
||||
ItemStack coal = ItemHelper.extract(contraption.inventory, FUEL_ITEMS, 1, false);
|
||||
if (!coal.isEmpty())
|
||||
fuel += 3600;
|
||||
}
|
||||
|
||||
if (fuel != fuelBefore || pushX != 0 || pushZ != 0) {
|
||||
nbt.putInt("Fuel", fuel);
|
||||
nbt.putDouble("PushX", 0);
|
||||
nbt.putDouble("PushZ", 0);
|
||||
furnaceCart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
super.tick();
|
||||
}
|
||||
|
||||
|
@ -383,7 +433,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
protected void readAdditional(CompoundNBT compound) {
|
||||
contraption = Contraption.fromNBT(world, compound.getCompound("Contraption"));
|
||||
initialAngle = compound.getFloat("InitialAngle");
|
||||
targetYaw = yaw = prevYaw = initialAngle;
|
||||
forceYaw(compound.contains("ForcedYaw") ? compound.getFloat("ForcedYaw") : initialAngle);
|
||||
dataManager.set(STALLED, compound.getBoolean("Stalled"));
|
||||
ListNBT vecNBT = compound.getList("CachedMotion", 6);
|
||||
if (!vecNBT.isEmpty()) {
|
||||
|
@ -396,6 +446,10 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
controllerPos = NBTUtil.readBlockPos(compound.getCompound("Controller"));
|
||||
}
|
||||
|
||||
public void forceYaw(float forcedYaw) {
|
||||
targetYaw = yaw = prevYaw = forcedYaw;
|
||||
}
|
||||
|
||||
public void checkController() {
|
||||
if (controllerPos == null)
|
||||
return;
|
||||
|
@ -415,14 +469,18 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
|
||||
@Override
|
||||
protected void writeAdditional(CompoundNBT compound) {
|
||||
compound.put("Contraption", getContraption().writeNBT());
|
||||
compound.putFloat("InitialAngle", initialAngle);
|
||||
if (!stationary)
|
||||
if (contraption != null)
|
||||
compound.put("Contraption", contraption.writeNBT());
|
||||
if (!stationary && motionBeforeStall != null)
|
||||
compound.put("CachedMotion",
|
||||
newDoubleNBTList(motionBeforeStall.x, motionBeforeStall.y, motionBeforeStall.z));
|
||||
compound.putBoolean("Stalled", isStalled());
|
||||
if (controllerPos != null)
|
||||
compound.put("Controller", NBTUtil.writeBlockPos(controllerPos));
|
||||
if (forcedAngle != -1)
|
||||
compound.putFloat("ForcedYaw", forcedAngle);
|
||||
|
||||
compound.putFloat("InitialAngle", initialAngle);
|
||||
compound.putBoolean("Stalled", isStalled());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -553,4 +611,18 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
super.setMotion(vec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getInitialAngle() {
|
||||
return initialAngle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.IProperty;
|
||||
|
@ -72,7 +74,7 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
|
||||
@Override
|
||||
public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (!cart.canBeRidden())
|
||||
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
||||
return;
|
||||
if (state.get(POWERED))
|
||||
disassemble(world, pos, cart);
|
||||
|
@ -90,13 +92,22 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
if (contraption.blocks.size() == 1)
|
||||
return;
|
||||
|
||||
float initialAngle = ContraptionEntity.yawFromVector(cart.getMotion());
|
||||
|
||||
int yawFromVector = (int) (ContraptionEntity.yawFromVector(cart.getMotion()) + .5d);
|
||||
yawFromVector = ((yawFromVector + 45) / 90) * 90;
|
||||
float initialAngle = yawFromVector;
|
||||
|
||||
withTileEntityDo(world, pos, te -> contraption.rotationMode = CartMovementMode.values()[te.movementMode.value]);
|
||||
ContraptionEntity entity = ContraptionEntity.createMounted(world, contraption, initialAngle);
|
||||
entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
world.addEntity(entity);
|
||||
entity.startRiding(cart);
|
||||
|
||||
if (cart instanceof FurnaceMinecartEntity) {
|
||||
CompoundNBT nbt = cart.serializeNBT();
|
||||
nbt.putDouble("PushZ", 0);
|
||||
nbt.putDouble("PushX", 0);
|
||||
cart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
protected void disassemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
|
@ -105,6 +116,13 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
if (!(cart.getPassengers().get(0) instanceof ContraptionEntity))
|
||||
return;
|
||||
cart.removePassengers();
|
||||
|
||||
if (cart instanceof FurnaceMinecartEntity) {
|
||||
CompoundNBT nbt = cart.serializeNBT();
|
||||
nbt.putDouble("PushZ", cart.getMotion().x);
|
||||
nbt.putDouble("PushX", cart.getMotion().z);
|
||||
cart.deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
package com.simibubi.create.modules.contraptions.components.contraptions.mounted;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.Contraption;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
||||
|
||||
import net.minecraft.block.AbstractRailBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.dispenser.IDispenseItemBehavior;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity.Type;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class MinecartContraptionItem extends Item {
|
||||
|
||||
private final AbstractMinecartEntity.Type minecartType;
|
||||
|
||||
public MinecartContraptionItem(Type minecartTypeIn, Properties builder) {
|
||||
super(builder);
|
||||
this.minecartType = minecartTypeIn;
|
||||
DispenserBlock.registerDispenseBehavior(this, DISPENSER_BEHAVIOR);
|
||||
}
|
||||
|
||||
// Taken and adjusted from MinecartItem
|
||||
private static final IDispenseItemBehavior DISPENSER_BEHAVIOR = new DefaultDispenseItemBehavior() {
|
||||
private final DefaultDispenseItemBehavior behaviourDefaultDispenseItem = new DefaultDispenseItemBehavior();
|
||||
|
||||
@Override
|
||||
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
||||
Direction direction = source.getBlockState().get(DispenserBlock.FACING);
|
||||
World world = source.getWorld();
|
||||
double d0 = source.getX() + (double) direction.getXOffset() * 1.125D;
|
||||
double d1 = Math.floor(source.getY()) + (double) direction.getYOffset();
|
||||
double d2 = source.getZ() + (double) direction.getZOffset() * 1.125D;
|
||||
BlockPos blockpos = source.getBlockPos().offset(direction);
|
||||
BlockState blockstate = world.getBlockState(blockpos);
|
||||
RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock
|
||||
? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null)
|
||||
: RailShape.NORTH_SOUTH;
|
||||
double d3;
|
||||
if (blockstate.isIn(BlockTags.RAILS)) {
|
||||
if (railshape.isAscending()) {
|
||||
d3 = 0.6D;
|
||||
} else {
|
||||
d3 = 0.1D;
|
||||
}
|
||||
} else {
|
||||
if (!blockstate.isAir(world, blockpos) || !world.getBlockState(blockpos.down()).isIn(BlockTags.RAILS)) {
|
||||
return this.behaviourDefaultDispenseItem.dispense(source, stack);
|
||||
}
|
||||
|
||||
BlockState blockstate1 = world.getBlockState(blockpos.down());
|
||||
RailShape railshape1 = blockstate1.getBlock() instanceof AbstractRailBlock
|
||||
? ((AbstractRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world,
|
||||
blockpos.down(), null)
|
||||
: RailShape.NORTH_SOUTH;
|
||||
if (direction != Direction.DOWN && railshape1.isAscending()) {
|
||||
d3 = -0.4D;
|
||||
} else {
|
||||
d3 = -0.9D;
|
||||
}
|
||||
}
|
||||
|
||||
AbstractMinecartEntity abstractminecartentity = AbstractMinecartEntity.create(world, d0, d1 + d3, d2,
|
||||
((MinecartContraptionItem) stack.getItem()).minecartType);
|
||||
if (stack.hasDisplayName())
|
||||
abstractminecartentity.setCustomName(stack.getDisplayName());
|
||||
world.addEntity(abstractminecartentity);
|
||||
addContraptionToMinecart(world, stack, abstractminecartentity, direction);
|
||||
|
||||
stack.shrink(1);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playDispenseSound(IBlockSource source) {
|
||||
source.getWorld().playEvent(1000, source.getBlockPos(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
// Taken and adjusted from MinecartItem
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
World world = context.getWorld();
|
||||
BlockPos blockpos = context.getPos();
|
||||
BlockState blockstate = world.getBlockState(blockpos);
|
||||
if (!blockstate.isIn(BlockTags.RAILS)) {
|
||||
return ActionResultType.FAIL;
|
||||
} else {
|
||||
ItemStack itemstack = context.getItem();
|
||||
if (!world.isRemote) {
|
||||
RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock
|
||||
? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos,
|
||||
null)
|
||||
: RailShape.NORTH_SOUTH;
|
||||
double d0 = 0.0D;
|
||||
if (railshape.isAscending()) {
|
||||
d0 = 0.5D;
|
||||
}
|
||||
|
||||
AbstractMinecartEntity abstractminecartentity = AbstractMinecartEntity.create(world,
|
||||
(double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.0625D + d0,
|
||||
(double) blockpos.getZ() + 0.5D, this.minecartType);
|
||||
if (itemstack.hasDisplayName())
|
||||
abstractminecartentity.setCustomName(itemstack.getDisplayName());
|
||||
PlayerEntity player = context.getPlayer();
|
||||
world.addEntity(abstractminecartentity);
|
||||
addContraptionToMinecart(world, itemstack, abstractminecartentity,
|
||||
player == null ? null : player.getHorizontalFacing());
|
||||
}
|
||||
|
||||
itemstack.shrink(1);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addContraptionToMinecart(World world, ItemStack itemstack,
|
||||
AbstractMinecartEntity abstractminecartentity, @Nullable Direction newFacing) {
|
||||
CompoundNBT tag = itemstack.getOrCreateTag();
|
||||
if (tag.contains("Contraption")) {
|
||||
CompoundNBT contraptionTag = tag.getCompound("Contraption");
|
||||
float initialAngle = contraptionTag.getFloat("InitialAngle");
|
||||
Contraption mountedContraption = Contraption.fromNBT(world, contraptionTag);
|
||||
ContraptionEntity contraption;
|
||||
|
||||
if (newFacing != null)
|
||||
contraption = ContraptionEntity.createMounted(world, mountedContraption, initialAngle, newFacing);
|
||||
else
|
||||
contraption = ContraptionEntity.createMounted(world, mountedContraption, initialAngle);
|
||||
|
||||
contraption.startRiding(abstractminecartentity);
|
||||
contraption.setPosition(abstractminecartentity.posX, abstractminecartentity.posY,
|
||||
abstractminecartentity.posZ);
|
||||
world.addEntity(contraption);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(ItemStack stack) {
|
||||
return "item.create.minecart_contraption";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void wrenchCanBeUsedToPickUpMinecartContraptions(PlayerInteractEvent.EntityInteract event) {
|
||||
Entity entity = event.getTarget();
|
||||
PlayerEntity player = event.getPlayer();
|
||||
if (player == null || entity == null)
|
||||
return;
|
||||
|
||||
ItemStack wrench = player.getHeldItem(event.getHand());
|
||||
if (!AllItems.WRENCH.typeOf(wrench))
|
||||
return;
|
||||
if (entity instanceof ContraptionEntity)
|
||||
entity = entity.getRidingEntity();
|
||||
if (!(entity instanceof AbstractMinecartEntity))
|
||||
return;
|
||||
AbstractMinecartEntity cart = (AbstractMinecartEntity) entity;
|
||||
Type type = cart.getMinecartType();
|
||||
if (type != Type.RIDEABLE && type != Type.FURNACE)
|
||||
return;
|
||||
List<Entity> passengers = cart.getPassengers();
|
||||
if (passengers.isEmpty() || !(passengers.get(0) instanceof ContraptionEntity))
|
||||
return;
|
||||
ContraptionEntity contraption = (ContraptionEntity) passengers.get(0);
|
||||
|
||||
if (!event.getWorld().isRemote) {
|
||||
player.inventory.placeItemBackInInventory(event.getWorld(), create(type, contraption));
|
||||
contraption.remove();
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
event.setCancellationResult(ActionResultType.SUCCESS);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
public static ItemStack create(Type type, ContraptionEntity entity) {
|
||||
ItemStack stack =
|
||||
(type == Type.RIDEABLE ? AllItems.MINECART_CONTRAPTION : AllItems.FURNACE_MINECART_CONTRAPTION).asStack();
|
||||
CompoundNBT tag = entity.getContraption().writeNBT();
|
||||
tag.remove("UUID");
|
||||
tag.remove("Pos");
|
||||
tag.remove("Motion");
|
||||
tag.putFloat("InitialAngle", entity.getInitialAngle());
|
||||
stack.getOrCreateTag().put("Contraption", tag);
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
|
|||
import com.simibubi.create.modules.contraptions.components.contraptions.AllContraptionTypes;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.BlockMovementTraits;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.Contraption;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.glue.SuperGlueEntity;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -169,6 +170,15 @@ public class PistonContraption extends Contraption {
|
|||
super.add(pos.offset(orientation, -initialExtensionProgress), capture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGlue(SuperGlueEntity entity) {
|
||||
BlockPos pos = entity.getHangingPosition();
|
||||
Direction direction = entity.getFacingDirection();
|
||||
BlockPos localPos = pos.subtract(anchor).offset(orientation, -initialExtensionProgress);
|
||||
this.superglue.add(Pair.of(localPos, direction));
|
||||
glueToRemove.add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlocksToWorld(World world, BlockPos offset, Vec3d rotation) {
|
||||
super.addBlocksToWorld(world, offset, rotation, (pos, state) -> {
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.simibubi.create.modules.curiosities.tools.SandPaperItem;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
|
@ -113,10 +114,10 @@ public class DeployerHandler {
|
|||
|
||||
// Check for entities
|
||||
final ServerWorld world = player.getServerWorld();
|
||||
List<LivingEntity> entities = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(clickedPos));
|
||||
List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(clickedPos));
|
||||
Hand hand = Hand.MAIN_HAND;
|
||||
if (!entities.isEmpty()) {
|
||||
LivingEntity entity = entities.get(world.rand.nextInt(entities.size()));
|
||||
Entity entity = entities.get(world.rand.nextInt(entities.size()));
|
||||
List<ItemEntity> capturedDrops = new ArrayList<>();
|
||||
boolean success = false;
|
||||
entity.captureDrops(capturedDrops);
|
||||
|
@ -131,7 +132,8 @@ public class DeployerHandler {
|
|||
if (cancelResult == null) {
|
||||
if (entity.processInitialInteract(player, hand))
|
||||
success = true;
|
||||
else if (stack.interactWithEntity(player, entity, hand))
|
||||
else if (entity instanceof LivingEntity
|
||||
&& stack.interactWithEntity(player, (LivingEntity) entity, hand))
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.client.renderer.RenderHelper;
|
|||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -48,15 +49,19 @@ public class DeployTool extends PlacementToolBase {
|
|||
double z = MathHelper.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z);
|
||||
|
||||
SchematicTransformation transformation = schematicHandler.getTransformation();
|
||||
Vec3d center = schematicHandler.getBounds().getCenter();
|
||||
Vec3d offset = transformation.getRotationOffset(true);
|
||||
AxisAlignedBB bounds = schematicHandler.getBounds();
|
||||
Vec3d center = bounds.getCenter();
|
||||
Vec3d rotationOffset = transformation.getRotationOffset(true);
|
||||
int centerX = (int) center.x;
|
||||
int centerZ = (int) center.z;
|
||||
double xOrigin = bounds.getXSize() / 2f;
|
||||
double zOrigin = bounds.getZSize() / 2f;
|
||||
|
||||
if (schematicHandler.getBounds().getXSize() % 2 == 1 || schematicHandler.getBounds().getZSize() % 2 == 1)
|
||||
GlStateManager.translated(.5f, 0, .5f);
|
||||
GlStateManager.translated(x, y, z);
|
||||
GlStateManager.translated(x - centerX, y, z - centerZ);
|
||||
GlStateManager.translated(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z);
|
||||
GlStateManager.rotated(transformation.getCurrentRotation(), 0, 1, 0);
|
||||
GlStateManager.translated(-offset.x, 0, -offset.z);
|
||||
GlStateManager.translated(-(center.x), 0, -(center.z));
|
||||
GlStateManager.translated(-rotationOffset.x, 0, -rotationOffset.z);
|
||||
GlStateManager.translated(-xOrigin, 0, -zOrigin);
|
||||
|
||||
schematicHandler.getOutline().setTextures(AllSpecialTextures.CHECKERED, null);
|
||||
schematicHandler.getOutline().render(Tessellator.getInstance().getBuffer());
|
||||
|
@ -66,14 +71,11 @@ public class DeployTool extends PlacementToolBase {
|
|||
|
||||
@Override
|
||||
public boolean handleMouseWheel(double delta) {
|
||||
|
||||
if (selectIgnoreBlocks) {
|
||||
selectionRange += delta;
|
||||
selectionRange = MathHelper.clamp(selectionRange, 1, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.handleMouseWheel(delta);
|
||||
if (!selectIgnoreBlocks)
|
||||
return super.handleMouseWheel(delta);
|
||||
selectionRange += delta;
|
||||
selectionRange = MathHelper.clamp(selectionRange, 1, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.simibubi.create.AllSpecialTextures;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.GlHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.foundation.utility.outliner.AABBOutline;
|
||||
|
||||
|
@ -89,8 +90,7 @@ public class FlipTool extends PlacementToolBase {
|
|||
Tessellator.getInstance().draw();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
||||
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10242, GL11.GL_REPEAT);
|
||||
GlStateManager.texParameter(GL11.GL_TEXTURE_2D, 10243, GL11.GL_REPEAT);
|
||||
GlHelper.enableTextureRepeat();
|
||||
GlStateManager.depthMask(false);
|
||||
Vec3d uDiff = v2.subtract(v1);
|
||||
Vec3d vDiff = v4.subtract(v1);
|
||||
|
@ -103,6 +103,7 @@ public class FlipTool extends PlacementToolBase {
|
|||
outline.putQuadUV(v2, v1, v4, v3, 0, 0, maxU, maxV, color, 1, buffer);
|
||||
Tessellator.getInstance().draw();
|
||||
GlStateManager.popMatrix();
|
||||
GlHelper.disableTextureRepeat();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
"item.create.sand_paper": "Sand Paper",
|
||||
"item.create.red_sand_paper": "Red Sand Paper",
|
||||
"item.create.super_glue": "Super Glue",
|
||||
"item.create.minecart_contraption": "Minecart with Contraption",
|
||||
|
||||
"item.create.brass_ingot": "Brass Ingot",
|
||||
"item.create.brass_sheet": "Brass Sheets",
|
||||
|
|
1156
src/main/resources/assets/create/lang/it_it.json
Normal file
1156
src/main/resources/assets/create/lang/it_it.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "create:item/minecart_contraption"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "create:item/minecart_contraption"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 582 B |
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"type": "crafting_shapeless",
|
||||
"ingredients": [
|
||||
[
|
||||
{
|
||||
"item": "create:minecart_contraption"
|
||||
},
|
||||
{
|
||||
"item": "create:furnace_minecart_contraption"
|
||||
}
|
||||
]
|
||||
],
|
||||
"result": {
|
||||
"item": "minecraft:minecart",
|
||||
"count": 1
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue