mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 16:33:42 +01:00
Merge branch 'mc1.16/dev' into flw/next
This commit is contained in:
commit
b0aba2d24a
23 changed files with 772 additions and 128 deletions
|
@ -3377,11 +3377,11 @@ bbf64f7eb3868e354756e57348493e2b1ae6b0d9 data/create/recipes/limestone_cobblesto
|
||||||
88fa2b1ab746d5e13a8afd6e7e7d80ad843e0016 data/create/recipes/limestone_cobblestone_wall_from_limestone_cobblestone_stonecutting.json
|
88fa2b1ab746d5e13a8afd6e7e7d80ad843e0016 data/create/recipes/limestone_cobblestone_wall_from_limestone_cobblestone_stonecutting.json
|
||||||
327bb8a6535b60bb65d0dda9d5205e988bc82526 data/create/recipes/limestone_pillar.json
|
327bb8a6535b60bb65d0dda9d5205e988bc82526 data/create/recipes/limestone_pillar.json
|
||||||
c2e15ac0c9109bad3face6d13efc32d7116b4c25 data/create/recipes/limestone_pillar_from_limestone_stonecutting.json
|
c2e15ac0c9109bad3face6d13efc32d7116b4c25 data/create/recipes/limestone_pillar_from_limestone_stonecutting.json
|
||||||
88173753ceaf121c5430bbf928a40e3c046dbfe0 data/create/recipes/mechanical_crafting/crushing_wheel.json
|
66674d07de63aada0991d2fdff07e22e00450135 data/create/recipes/mechanical_crafting/crushing_wheel.json
|
||||||
14e322d4de8fae35d952274376497740bb3d5962 data/create/recipes/mechanical_crafting/extendo_grip.json
|
599f8b87c24c131350ba7ceb69a0c8b9829c62bc data/create/recipes/mechanical_crafting/extendo_grip.json
|
||||||
de7fea84434753873dfa2b929d9b5f5f86ac6a5c data/create/recipes/mechanical_crafting/flywheel.json
|
f26ed47c10cc63613759b0f8ae4ef349000de60d data/create/recipes/mechanical_crafting/flywheel.json
|
||||||
e491fd8a8873308270f9dc2a57ac8f2c70431dcc data/create/recipes/mechanical_crafting/furnace_engine.json
|
2dc00d6e4c159e06ab2a705e666e83e4238a7814 data/create/recipes/mechanical_crafting/furnace_engine.json
|
||||||
8e5224d22b228f69473ca48ca0d874b34660b573 data/create/recipes/mechanical_crafting/potato_cannon.json
|
b77911c169b6205a09001a09ca074eb2234f0d29 data/create/recipes/mechanical_crafting/potato_cannon.json
|
||||||
98f877bf8f3f8a686fc6cf7479a0fba5744248ce data/create/recipes/milling/allium.json
|
98f877bf8f3f8a686fc6cf7479a0fba5744248ce data/create/recipes/milling/allium.json
|
||||||
8c7e1cbc87c7ca7df2bf949957e89422fef8ad94 data/create/recipes/milling/aluminum_ore.json
|
8c7e1cbc87c7ca7df2bf949957e89422fef8ad94 data/create/recipes/milling/aluminum_ore.json
|
||||||
bcff4d30ae09a0729bce8b2dbde4ddd6719a998b data/create/recipes/milling/andesite.json
|
bcff4d30ae09a0729bce8b2dbde4ddd6719a998b data/create/recipes/milling/andesite.json
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
"result": {
|
"result": {
|
||||||
"item": "create:crushing_wheel",
|
"item": "create:crushing_wheel",
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
},
|
||||||
|
"acceptMirrored": false
|
||||||
}
|
}
|
|
@ -23,5 +23,6 @@
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"item": "create:extendo_grip"
|
"item": "create:extendo_grip"
|
||||||
}
|
},
|
||||||
|
"acceptMirrored": false
|
||||||
}
|
}
|
|
@ -15,5 +15,6 @@
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"item": "create:flywheel"
|
"item": "create:flywheel"
|
||||||
}
|
},
|
||||||
|
"acceptMirrored": true
|
||||||
}
|
}
|
|
@ -26,5 +26,6 @@
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"item": "create:furnace_engine"
|
"item": "create:furnace_engine"
|
||||||
}
|
},
|
||||||
|
"acceptMirrored": true
|
||||||
}
|
}
|
|
@ -20,5 +20,6 @@
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"item": "create:potato_cannon"
|
"item": "create:potato_cannon"
|
||||||
}
|
},
|
||||||
|
"acceptMirrored": true
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
|
@ -73,17 +72,10 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
|
||||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||||
|
|
||||||
ItemStack itemOutput = recipe.getRollableResultsAsItemStacks()
|
|
||||||
.isEmpty() ? ItemStack.EMPTY
|
|
||||||
: recipe.getRollableResultsAsItemStacks()
|
|
||||||
.get(0);
|
|
||||||
FluidStack fluidOutput = recipe.getFluidResults()
|
|
||||||
.isEmpty() ? FluidStack.EMPTY
|
|
||||||
: recipe.getFluidResults()
|
|
||||||
.get(0);
|
|
||||||
|
|
||||||
NonNullList<FluidIngredient> fluidIngredients = recipe.getFluidIngredients();
|
NonNullList<FluidIngredient> fluidIngredients = recipe.getFluidIngredients();
|
||||||
List<Pair<Ingredient, MutableInt>> ingredients = ItemHelper.condenseIngredients(recipe.getIngredients());
|
List<Pair<Ingredient, MutableInt>> ingredients = ItemHelper.condenseIngredients(recipe.getIngredients());
|
||||||
|
List<ItemStack> itemOutputs = recipe.getRollableResultsAsItemStacks();
|
||||||
|
NonNullList<FluidStack> fluidOutputs = recipe.getFluidResults();
|
||||||
|
|
||||||
int size = ingredients.size() + fluidIngredients.size();
|
int size = ingredients.size() + fluidIngredients.size();
|
||||||
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
||||||
|
@ -115,28 +107,41 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
|
||||||
fluidStacks.set(j, withImprovedVisibility(stacks));
|
fluidStacks.set(j, withImprovedVisibility(stacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!itemOutput.isEmpty()) {
|
int outSize = fluidOutputs.size() + recipe.getRollableResults()
|
||||||
itemStacks.init(i, false, 141, 50 + yOffset);
|
.size();
|
||||||
itemStacks.set(i, recipe.getResultItem()
|
int outputIndex = 0;
|
||||||
.getStack());
|
|
||||||
yOffset -= 19;
|
if (!itemOutputs.isEmpty())
|
||||||
|
addStochasticTooltip(itemStacks, recipe.getRollableResults(), i);
|
||||||
|
|
||||||
|
for (; outputIndex < outSize; outputIndex++) {
|
||||||
|
int xPosition = 141 - (outSize % 2 != 0 && outputIndex == outSize - 1 ? 0 : outputIndex % 2 == 0 ? 10 : -9);
|
||||||
|
int yPosition = -19 * (outputIndex / 2) + 50 + yOffset;
|
||||||
|
|
||||||
|
if (itemOutputs.size() > outputIndex) {
|
||||||
|
itemStacks.init(i, false, xPosition, yPosition + yOffset);
|
||||||
|
itemStacks.set(i, itemOutputs.get(outputIndex));
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
fluidStacks.init(j, false, xPosition + 1, yPosition + 1 + yOffset);
|
||||||
|
fluidStacks.set(j, withImprovedVisibility(fluidOutputs.get(outputIndex - itemOutputs.size())));
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fluidOutput.isEmpty()) {
|
addFluidTooltip(fluidStacks, fluidIngredients, fluidOutputs);
|
||||||
fluidStacks.init(j, false, 142, 51 + yOffset);
|
|
||||||
fluidStacks.set(j, withImprovedVisibility(fluidOutput));
|
|
||||||
}
|
|
||||||
|
|
||||||
addFluidTooltip(fluidStacks, fluidIngredients, ImmutableList.of(fluidOutput));
|
|
||||||
|
|
||||||
HeatCondition requiredHeat = recipe.getRequiredHeat();
|
HeatCondition requiredHeat = recipe.getRequiredHeat();
|
||||||
if (!requiredHeat.testBlazeBurner(HeatLevel.NONE)) {
|
if (!requiredHeat.testBlazeBurner(HeatLevel.NONE)) {
|
||||||
itemStacks.init(++i, true, 133, 80);
|
itemStacks.init(i, true, 133, 80);
|
||||||
itemStacks.set(i, AllBlocks.BLAZE_BURNER.asStack());
|
itemStacks.set(i, AllBlocks.BLAZE_BURNER.asStack());
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
if (!requiredHeat.testBlazeBurner(HeatLevel.KINDLED)) {
|
if (!requiredHeat.testBlazeBurner(HeatLevel.KINDLED)) {
|
||||||
itemStacks.init(++i, true, 152, 80);
|
itemStacks.init(i, true, 152, 80);
|
||||||
itemStacks.set(i, AllItems.BLAZE_CAKE.asStack());
|
itemStacks.set(i, AllItems.BLAZE_CAKE.asStack());
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +151,8 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
|
||||||
|
|
||||||
int size = actualIngredients.size() + recipe.getFluidIngredients()
|
int size = actualIngredients.size() + recipe.getFluidIngredients()
|
||||||
.size();
|
.size();
|
||||||
|
int outSize = recipe.getFluidResults().size() + recipe.getRollableResults().size();
|
||||||
|
|
||||||
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
||||||
HeatCondition requiredHeat = recipe.getRequiredHeat();
|
HeatCondition requiredHeat = recipe.getRequiredHeat();
|
||||||
int yOffset = 0;
|
int yOffset = 0;
|
||||||
|
@ -154,8 +161,13 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
|
||||||
AllGuiTextures.JEI_SLOT.draw(matrixStack, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
|
AllGuiTextures.JEI_SLOT.draw(matrixStack, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
|
||||||
|
|
||||||
boolean noHeat = requiredHeat == HeatCondition.NONE;
|
boolean noHeat = requiredHeat == HeatCondition.NONE;
|
||||||
AllGuiTextures.JEI_SLOT.draw(matrixStack, 141, 50 + yOffset);
|
|
||||||
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 136, 32 + yOffset);
|
int vRows = (1 + outSize) / 2;
|
||||||
|
for (int i = 0; i < outSize; i++)
|
||||||
|
AllGuiTextures.JEI_SLOT.draw(matrixStack,
|
||||||
|
141 - (outSize % 2 != 0 && i == outSize - 1 ? 0 : i % 2 == 0 ? 10 : -9), -19 * (i / 2) + 50 + yOffset);
|
||||||
|
if (vRows <= 2)
|
||||||
|
AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 136, -19 * (vRows - 1) + 32 + yOffset);
|
||||||
|
|
||||||
AllGuiTextures shadow = noHeat ? AllGuiTextures.JEI_SHADOW : AllGuiTextures.JEI_LIGHT;
|
AllGuiTextures shadow = noHeat ? AllGuiTextures.JEI_SHADOW : AllGuiTextures.JEI_LIGHT;
|
||||||
shadow.draw(matrixStack, 81, 58 + (noHeat ? 10 : 30));
|
shadow.draw(matrixStack, 81, 58 + (noHeat ? 10 : 30));
|
||||||
|
|
|
@ -16,19 +16,20 @@ import com.simibubi.create.foundation.utility.BlockHelper;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
|
import net.minecraft.block.AbstractPlantBlock;
|
||||||
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;
|
||||||
import net.minecraft.block.CocoaBlock;
|
import net.minecraft.block.CocoaBlock;
|
||||||
import net.minecraft.block.CropsBlock;
|
import net.minecraft.block.CropsBlock;
|
||||||
import net.minecraft.block.KelpBlock;
|
|
||||||
import net.minecraft.block.KelpTopBlock;
|
|
||||||
import net.minecraft.block.SugarCaneBlock;
|
import net.minecraft.block.SugarCaneBlock;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.state.IntegerProperty;
|
import net.minecraft.state.IntegerProperty;
|
||||||
import net.minecraft.state.Property;
|
import net.minecraft.state.Property;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -83,9 +84,17 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemStack item = ItemStack.EMPTY;
|
||||||
|
float effectChance = 1;
|
||||||
|
|
||||||
|
if (stateVisited.getBlock().is(BlockTags.LEAVES)) {
|
||||||
|
item = new ItemStack(Items.SHEARS);
|
||||||
|
effectChance = .45f;
|
||||||
|
}
|
||||||
|
|
||||||
MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable);
|
MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable);
|
||||||
BlockState state = stateVisited;
|
BlockState state = stateVisited;
|
||||||
BlockHelper.destroyBlock(world, pos, 1, stack -> {
|
BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> {
|
||||||
if (!seedSubtracted.getValue() && stack.sameItem(new ItemStack(state.getBlock()))) {
|
if (!seedSubtracted.getValue() && stack.sameItem(new ItemStack(state.getBlock()))) {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
seedSubtracted.setTrue();
|
seedSubtracted.setTrue();
|
||||||
|
@ -127,12 +136,12 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
return false;
|
return false;
|
||||||
if (state.getBlock() instanceof SugarCaneBlock)
|
if (state.getBlock() instanceof SugarCaneBlock)
|
||||||
return true;
|
return true;
|
||||||
|
if (state.getBlock().is(BlockTags.LEAVES))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (state.getCollisionShape(world, pos)
|
if (state.getCollisionShape(world, pos)
|
||||||
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||||
if (state.getBlock() instanceof KelpBlock)
|
if (state.getBlock() instanceof AbstractPlantBlock)
|
||||||
return true;
|
|
||||||
if (state.getBlock() instanceof KelpTopBlock)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (Property<?> property : state.getProperties()) {
|
for (Property<?> property : state.getProperties()) {
|
||||||
|
@ -160,7 +169,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
if (block == Blocks.SWEET_BERRY_BUSH) {
|
if (block == Blocks.SWEET_BERRY_BUSH) {
|
||||||
return state.setValue(BlockStateProperties.AGE_3, Integer.valueOf(1));
|
return state.setValue(BlockStateProperties.AGE_3, Integer.valueOf(1));
|
||||||
}
|
}
|
||||||
if (block == Blocks.SUGAR_CANE || block == Blocks.KELP) {
|
if (block == Blocks.SUGAR_CANE || block instanceof AbstractPlantBlock) {
|
||||||
if (state.getFluidState()
|
if (state.getFluidState()
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
return Blocks.AIR.defaultBlockState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
|
|
|
@ -17,6 +17,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
import com.simibubi.create.foundation.utility.Pointing;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -43,14 +44,16 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
Direction facing = te.getBlockState()
|
Direction facing = te.getBlockState()
|
||||||
.getValue(HORIZONTAL_FACING);
|
.getValue(HORIZONTAL_FACING);
|
||||||
Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()).scale(.58)
|
Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal())
|
||||||
|
.scale(.58)
|
||||||
.add(.5, .5, .5);
|
.add(.5, .5, .5);
|
||||||
|
|
||||||
if (te.phase == Phase.EXPORTING) {
|
if (te.phase == Phase.EXPORTING) {
|
||||||
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState());
|
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState());
|
||||||
float progress =
|
float progress =
|
||||||
MathHelper.clamp((1000 - te.countDown + te.getCountDownSpeed() * partialTicks) / 1000f, 0, 1);
|
MathHelper.clamp((1000 - te.countDown + te.getCountDownSpeed() * partialTicks) / 1000f, 0, 1);
|
||||||
vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal()).scale(progress * .75f));
|
vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal())
|
||||||
|
.scale(progress * .75f));
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.translate(vec.x, vec.y, vec.z);
|
ms.translate(vec.x, vec.y, vec.z);
|
||||||
|
@ -66,10 +69,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms,
|
public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
if (te.phase == Phase.IDLE) {
|
if (te.phase == Phase.IDLE) {
|
||||||
ItemStack stack = te.getInventory().getItem(0);
|
ItemStack stack = te.getInventory()
|
||||||
|
.getItem(0);
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(0, 0, -1 / 256f);
|
ms.translate(0, 0, -1 / 256f);
|
||||||
|
ms.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
Minecraft.getInstance()
|
Minecraft.getInstance()
|
||||||
.getItemRenderer()
|
.getItemRenderer()
|
||||||
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||||
|
@ -111,9 +116,16 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
Integer x = pair.getKey();
|
Integer x = pair.getKey();
|
||||||
Integer y = pair.getValue();
|
Integer y = pair.getValue();
|
||||||
ms.translate(x * spacing, y * spacing, 0);
|
ms.translate(x * spacing, y * spacing, 0);
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
if (te.phase == Phase.EXPORTING && te.getBlockState().hasProperty(MechanicalCrafterBlock.POINTING)) {
|
||||||
|
Pointing value = te.getBlockState().getValue(MechanicalCrafterBlock.POINTING);
|
||||||
|
offset = value == Pointing.UP ? -1 : value == Pointing.LEFT ? 2 : value == Pointing.RIGHT ? -2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
MatrixTransformStack.of(ms)
|
MatrixTransformStack.of(ms)
|
||||||
.nudge(x * 13 + y + te.getBlockPos()
|
.rotateY(180)
|
||||||
.hashCode());
|
.translate(0, 0, (x + y * 3 + offset * 9) / 1024f );
|
||||||
Minecraft.getInstance()
|
Minecraft.getInstance()
|
||||||
.getItemRenderer()
|
.getItemRenderer()
|
||||||
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||||
|
@ -141,9 +153,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
|| pair.getRight()
|
|| pair.getRight()
|
||||||
.intValue() != 0)
|
.intValue() != 0)
|
||||||
return;
|
return;
|
||||||
|
ms.pushPose();
|
||||||
|
ms.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
Minecraft.getInstance()
|
Minecraft.getInstance()
|
||||||
.getItemRenderer()
|
.getItemRenderer()
|
||||||
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||||
|
ms.popPose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +170,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
|
||||||
|
|
||||||
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
|
if (!Backend.getInstance()
|
||||||
|
.canUseInstancing(te.getLevel())) {
|
||||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
||||||
standardKineticRotationTransform(superBuffer, te, light);
|
standardKineticRotationTransform(superBuffer, te, light);
|
||||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING)
|
||||||
|
.getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
||||||
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
||||||
superBuffer.renderInto(ms, vb);
|
superBuffer.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
@ -167,14 +184,13 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
BlockPos pos = te.getBlockPos();
|
BlockPos pos = te.getBlockPos();
|
||||||
|
|
||||||
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) {
|
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) {
|
||||||
SuperByteBuffer lidBuffer =
|
SuperByteBuffer lidBuffer = renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState);
|
||||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState);
|
lidBuffer.light(light)
|
||||||
lidBuffer.light(light).renderInto(ms, vb);
|
.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MechanicalCrafterBlock.isValidTarget(te.getLevel(), pos.relative(targetDirection), blockState)) {
|
if (MechanicalCrafterBlock.isValidTarget(te.getLevel(), pos.relative(targetDirection), blockState)) {
|
||||||
SuperByteBuffer beltBuffer =
|
SuperByteBuffer beltBuffer = renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState);
|
||||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState);
|
|
||||||
SuperByteBuffer beltFrameBuffer =
|
SuperByteBuffer beltFrameBuffer =
|
||||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState);
|
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState);
|
||||||
|
|
||||||
|
@ -183,13 +199,15 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
|
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
beltBuffer.light(light).renderInto(ms, vb);
|
beltBuffer.light(light)
|
||||||
beltFrameBuffer.light(light).renderInto(ms, vb);
|
.renderInto(ms, vb);
|
||||||
|
beltFrameBuffer.light(light)
|
||||||
|
.renderInto(ms, vb);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SuperByteBuffer arrowBuffer =
|
SuperByteBuffer arrowBuffer = renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState);
|
||||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState);
|
arrowBuffer.light(light)
|
||||||
arrowBuffer.light(light).renderInto(ms, vb);
|
.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -197,7 +215,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) {
|
private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) {
|
||||||
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
|
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
|
||||||
float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING)
|
float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING)
|
||||||
.getXRotation();
|
.getXRotation();
|
||||||
float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING));
|
float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING));
|
||||||
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
|
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
|
||||||
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
||||||
|
|
|
@ -10,25 +10,58 @@ import net.minecraft.item.crafting.IRecipeType;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.item.crafting.ShapedRecipe;
|
import net.minecraft.item.crafting.ShapedRecipe;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.JSONUtils;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class MechanicalCraftingRecipe extends ShapedRecipe {
|
public class MechanicalCraftingRecipe extends ShapedRecipe {
|
||||||
|
|
||||||
|
private boolean acceptMirrored;
|
||||||
|
|
||||||
public MechanicalCraftingRecipe(ResourceLocation idIn, String groupIn, int recipeWidthIn, int recipeHeightIn,
|
public MechanicalCraftingRecipe(ResourceLocation idIn, String groupIn, int recipeWidthIn, int recipeHeightIn,
|
||||||
NonNullList<Ingredient> recipeItemsIn, ItemStack recipeOutputIn) {
|
NonNullList<Ingredient> recipeItemsIn, ItemStack recipeOutputIn, boolean acceptMirrored) {
|
||||||
super(idIn, groupIn, recipeWidthIn, recipeHeightIn, recipeItemsIn, recipeOutputIn);
|
super(idIn, groupIn, recipeWidthIn, recipeHeightIn, recipeItemsIn, recipeOutputIn);
|
||||||
|
this.acceptMirrored = acceptMirrored;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MechanicalCraftingRecipe fromShaped(ShapedRecipe recipe) {
|
private static MechanicalCraftingRecipe fromShaped(ShapedRecipe recipe, boolean acceptMirrored) {
|
||||||
return new MechanicalCraftingRecipe(recipe.getId(), recipe.getGroup(), recipe.getWidth(), recipe.getHeight(),
|
return new MechanicalCraftingRecipe(recipe.getId(), recipe.getGroup(), recipe.getWidth(), recipe.getHeight(),
|
||||||
recipe.getIngredients(), recipe.getResultItem());
|
recipe.getIngredients(), recipe.getResultItem(), acceptMirrored);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(CraftingInventory inv, World worldIn) {
|
public boolean matches(CraftingInventory inv, World worldIn) {
|
||||||
return inv instanceof MechanicalCraftingInventory && super.matches(inv, worldIn);
|
if (!(inv instanceof MechanicalCraftingInventory))
|
||||||
|
return false;
|
||||||
|
if (acceptsMirrored())
|
||||||
|
return super.matches(inv, worldIn);
|
||||||
|
|
||||||
|
// From ShapedRecipe except the symmetry
|
||||||
|
for (int i = 0; i <= inv.getWidth() - this.getWidth(); ++i)
|
||||||
|
for (int j = 0; j <= inv.getHeight() - this.getHeight(); ++j)
|
||||||
|
if (this.matchesSpecific(inv, i, j))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// From ShapedRecipe
|
||||||
|
private boolean matchesSpecific(CraftingInventory inv, int p_77573_2_, int p_77573_3_) {
|
||||||
|
NonNullList<Ingredient> ingredients = getIngredients();
|
||||||
|
int width = getWidth();
|
||||||
|
int height = getHeight();
|
||||||
|
for (int i = 0; i < inv.getWidth(); ++i) {
|
||||||
|
for (int j = 0; j < inv.getHeight(); ++j) {
|
||||||
|
int k = i - p_77573_2_;
|
||||||
|
int l = j - p_77573_3_;
|
||||||
|
Ingredient ingredient = Ingredient.EMPTY;
|
||||||
|
if (k >= 0 && l >= 0 && k < width && l < height)
|
||||||
|
ingredient = ingredients.get(k + l * width);
|
||||||
|
if (!ingredient.test(inv.getItem(i + j * inv.getWidth())))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,16 +79,30 @@ public class MechanicalCraftingRecipe extends ShapedRecipe {
|
||||||
return AllRecipeTypes.MECHANICAL_CRAFTING.getSerializer();
|
return AllRecipeTypes.MECHANICAL_CRAFTING.getSerializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean acceptsMirrored() {
|
||||||
|
return acceptMirrored;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Serializer extends ShapedRecipe.Serializer {
|
public static class Serializer extends ShapedRecipe.Serializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShapedRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
public ShapedRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||||
return fromShaped(super.fromJson(recipeId, json));
|
return fromShaped(super.fromJson(recipeId, json), JSONUtils.getAsBoolean(json, "acceptMirrored", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShapedRecipe fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) {
|
public ShapedRecipe fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) {
|
||||||
return fromShaped(super.fromNetwork(recipeId, buffer));
|
return fromShaped(super.fromNetwork(recipeId, buffer), buffer.readBoolean() && buffer.readBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNetwork(PacketBuffer p_199427_1_, ShapedRecipe p_199427_2_) {
|
||||||
|
super.toNetwork(p_199427_1_, p_199427_2_);
|
||||||
|
if (p_199427_2_ instanceof MechanicalCraftingRecipe) {
|
||||||
|
p_199427_1_.writeBoolean(true);
|
||||||
|
p_199427_1_.writeBoolean(((MechanicalCraftingRecipe) p_199427_2_).acceptsMirrored());
|
||||||
|
} else
|
||||||
|
p_199427_1_.writeBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllTags;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
|
@ -205,7 +206,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canDrainInfinitely(Fluid fluid) {
|
protected boolean canDrainInfinitely(Fluid fluid) {
|
||||||
return maxBlocks() != -1; // && !AllFluidTags.NO_INFINITE_DRAINING.matches(fluid);
|
return maxBlocks() != -1 && !AllTags.AllFluidTags.NO_INFINITE_DRAINING.matches(fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
|
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
|
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.BeltSlicer.Feedback;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType;
|
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltMovementHandler.TransportedEntityInfo;
|
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltMovementHandler.TransportedEntityInfo;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltTunnelInteractionHandler;
|
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltTunnelInteractionHandler;
|
||||||
|
@ -96,7 +97,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean areStatesKineticallyEquivalent(BlockState oldState, BlockState newState) {
|
protected boolean areStatesKineticallyEquivalent(BlockState oldState, BlockState newState) {
|
||||||
return super.areStatesKineticallyEquivalent(oldState, newState) && oldState.getValue(PART) == newState.getValue(PART);
|
return super.areStatesKineticallyEquivalent(oldState, newState)
|
||||||
|
&& oldState.getValue(PART) == newState.getValue(PART);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,7 +106,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
if (face.getAxis() != getRotationAxis(state))
|
if (face.getAxis() != getRotationAxis(state))
|
||||||
return false;
|
return false;
|
||||||
return getTileEntityOptional(world, pos).map(BeltTileEntity::hasPulley)
|
return getTileEntityOptional(world, pos).map(BeltTileEntity::hasPulley)
|
||||||
.orElse(false);
|
.orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,15 +124,6 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
return AllItems.BELT_CONNECTOR.asStack();
|
return AllItems.BELT_CONNECTOR.asStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME
|
|
||||||
*
|
|
||||||
* @Override
|
|
||||||
* public Material getMaterial(BlockState state) {
|
|
||||||
* return state.get(CASING) ? Material.WOOD : Material.WOOL;
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(BlockState state, net.minecraft.loot.LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, net.minecraft.loot.LootContext.Builder builder) {
|
||||||
|
@ -241,6 +234,9 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
if (player.isShiftKeyDown() || !player.mayBuild())
|
if (player.isShiftKeyDown() || !player.mayBuild())
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
ItemStack heldItem = player.getItemInHand(handIn);
|
ItemStack heldItem = player.getItemInHand(handIn);
|
||||||
|
|
||||||
|
boolean isWrench = AllItems.WRENCH.isIn(heldItem);
|
||||||
|
boolean isConnector = AllItems.BELT_CONNECTOR.isIn(heldItem);
|
||||||
boolean isShaft = AllBlocks.SHAFT.isIn(heldItem);
|
boolean isShaft = AllBlocks.SHAFT.isIn(heldItem);
|
||||||
boolean isDye = Tags.Items.DYES.contains(heldItem.getItem());
|
boolean isDye = Tags.Items.DYES.contains(heldItem.getItem());
|
||||||
boolean hasWater = EmptyingByBasin.emptyItem(world, heldItem, true)
|
boolean hasWater = EmptyingByBasin.emptyItem(world, heldItem, true)
|
||||||
|
@ -255,6 +251,11 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isConnector)
|
||||||
|
return BeltSlicer.useConnector(state, world, pos, player, handIn, hit, new Feedback());
|
||||||
|
if (isWrench)
|
||||||
|
return BeltSlicer.useWrench(state, world, pos, player, handIn, hit, new Feedback());
|
||||||
|
|
||||||
BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos);
|
BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos);
|
||||||
if (belt == null)
|
if (belt == null)
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
|
@ -274,7 +275,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
});
|
});
|
||||||
if (success.isTrue())
|
if (success.isTrue())
|
||||||
world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f,
|
world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f,
|
||||||
1f + Create.RANDOM.nextFloat());
|
1f + Create.RANDOM.nextFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShaft) {
|
if (isShaft) {
|
||||||
|
@ -329,7 +330,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -378,7 +379,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
return BeltShapes.getCollisionShape(state);
|
return BeltShapes.getCollisionShape(state);
|
||||||
return shape;
|
return shape;
|
||||||
|
|
||||||
}).orElse(shape);
|
})
|
||||||
|
.orElse(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -499,8 +501,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, IWorld world,
|
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, IWorld world, BlockPos pos,
|
||||||
BlockPos pos, BlockPos p_196271_6_) {
|
BlockPos p_196271_6_) {
|
||||||
if (side.getAxis()
|
if (side.getAxis()
|
||||||
.isHorizontal())
|
.isHorizontal())
|
||||||
updateTunnelConnections(world, pos.above());
|
updateTunnelConnections(world, pos.above());
|
||||||
|
@ -552,29 +554,6 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canAccessFromSide(Direction facing, BlockState belt) {
|
public static boolean canAccessFromSide(Direction facing, BlockState belt) {
|
||||||
// if (facing == null)
|
|
||||||
// return true;
|
|
||||||
// if (!belt.get(BeltBlock.CASING))
|
|
||||||
// return false;
|
|
||||||
// BeltPart part = belt.get(BeltBlock.PART);
|
|
||||||
// if (part != BeltPart.MIDDLE && facing.getAxis() == belt.get(HORIZONTAL_FACING)
|
|
||||||
// .rotateY()
|
|
||||||
// .getAxis())
|
|
||||||
// return false;
|
|
||||||
//
|
|
||||||
// BeltSlope slope = belt.get(BeltBlock.SLOPE);
|
|
||||||
// if (slope != BeltSlope.HORIZONTAL) {
|
|
||||||
// if (slope == BeltSlope.DOWNWARD && part == BeltPart.END)
|
|
||||||
// return true;
|
|
||||||
// if (slope == BeltSlope.UPWARD && part == BeltPart.START)
|
|
||||||
// return true;
|
|
||||||
// Direction beltSide = belt.get(HORIZONTAL_FACING);
|
|
||||||
// if (slope == BeltSlope.DOWNWARD)
|
|
||||||
// beltSide = beltSide.getOpposite();
|
|
||||||
// if (beltSide == facing)
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.relays.belt;
|
||||||
import com.simibubi.create.AllTags.AllItemTags;
|
import com.simibubi.create.AllTags.AllItemTags;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -75,7 +76,8 @@ public class BeltHelper {
|
||||||
verticalMovement = verticalMovement * (Math.min(offset, controller.beltLength - .5f) - .5f);
|
verticalMovement = verticalMovement * (Math.min(offset, controller.beltLength - .5f) - .5f);
|
||||||
Vector3d vec = VecHelper.getCenterOf(controller.getBlockPos());
|
Vector3d vec = VecHelper.getCenterOf(controller.getBlockPos());
|
||||||
Vector3d horizontalMovement = Vector3d.atLowerCornerOf(controller.getBeltFacing()
|
Vector3d horizontalMovement = Vector3d.atLowerCornerOf(controller.getBeltFacing()
|
||||||
.getNormal()).scale(offset - .5f);
|
.getNormal())
|
||||||
|
.scale(offset - .5f);
|
||||||
|
|
||||||
if (slope == BeltSlope.VERTICAL)
|
if (slope == BeltSlope.VERTICAL)
|
||||||
horizontalMovement = Vector3d.ZERO;
|
horizontalMovement = Vector3d.ZERO;
|
||||||
|
@ -85,4 +87,16 @@ public class BeltHelper {
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector3d getBeltVector(BlockState state) {
|
||||||
|
BeltSlope slope = state.getValue(BeltBlock.SLOPE);
|
||||||
|
int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0;
|
||||||
|
Vector3d horizontalMovement = Vector3d.atLowerCornerOf(state.getValue(BeltBlock.HORIZONTAL_FACING)
|
||||||
|
.getNormal());
|
||||||
|
if (slope == BeltSlope.VERTICAL)
|
||||||
|
return new Vector3d(0, state.getValue(BeltBlock.HORIZONTAL_FACING)
|
||||||
|
.getAxisDirection()
|
||||||
|
.getStep(), 0);
|
||||||
|
return new Vector3d(0, verticality, 0).add(horizontalMovement);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,8 +301,8 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
|
|
||||||
protected int getPackedLight(BeltTileEntity controller, float beltPos) {
|
protected int getPackedLight(BeltTileEntity controller, float beltPos) {
|
||||||
int segment = (int) Math.floor(beltPos) * 2;
|
int segment = (int) Math.floor(beltPos) * 2;
|
||||||
|
if (controller.light == null || segment >= controller.light.length || segment < 0)
|
||||||
if (controller.light == null || segment >= controller.light.length) return 0;
|
return 0;
|
||||||
|
|
||||||
return (controller.light[segment + 1] << 20) | (controller.light[segment] << 4);
|
return (controller.light[segment + 1] << 20) | (controller.light[segment] << 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,472 @@
|
||||||
|
package com.simibubi.create.content.contraptions.relays.belt;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.AllItems;
|
||||||
|
import com.simibubi.create.CreateClient;
|
||||||
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorItem;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltInventory;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.DyeColor;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.util.Constants.BlockFlags;
|
||||||
|
|
||||||
|
public class BeltSlicer {
|
||||||
|
|
||||||
|
public static class Feedback {
|
||||||
|
int color = 0xffffff;
|
||||||
|
AxisAlignedBB bb;
|
||||||
|
String langKey;
|
||||||
|
TextFormatting formatting = TextFormatting.WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ActionResultType useWrench(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||||
|
Hand handIn, BlockRayTraceResult hit, Feedback feedBack) {
|
||||||
|
BeltTileEntity controllerTE = BeltHelper.getControllerTE(world, pos);
|
||||||
|
if (controllerTE == null)
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
if (state.getValue(BeltBlock.CASING) && hit.getDirection() != Direction.UP)
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
if (state.getValue(BeltBlock.PART) == BeltPart.PULLEY && hit.getDirection()
|
||||||
|
.getAxis() != Axis.Y)
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
|
int beltLength = controllerTE.beltLength;
|
||||||
|
if (beltLength == 2)
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
BlockPos beltVector = new BlockPos(BeltHelper.getBeltVector(state));
|
||||||
|
BeltPart part = state.getValue(BeltBlock.PART);
|
||||||
|
List<BlockPos> beltChain = BeltBlock.getBeltChain(world, controllerTE.getBlockPos());
|
||||||
|
boolean creative = player.isCreative();
|
||||||
|
|
||||||
|
// Shorten from End
|
||||||
|
if (hoveringEnd(state, hit)) {
|
||||||
|
if (world.isClientSide)
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
|
for (BlockPos blockPos : beltChain) {
|
||||||
|
BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos);
|
||||||
|
if (belt == null)
|
||||||
|
continue;
|
||||||
|
belt.detachKinetics();
|
||||||
|
belt.invalidateItemHandler();
|
||||||
|
belt.beltLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeltInventory inventory = controllerTE.inventory;
|
||||||
|
BlockPos next = part == BeltPart.END ? pos.subtract(beltVector) : pos.offset(beltVector);
|
||||||
|
BlockState replacedState = world.getBlockState(next);
|
||||||
|
BeltTileEntity segmentTE = BeltHelper.getSegmentTE(world, next);
|
||||||
|
KineticTileEntity.switchToBlockState(world, next,
|
||||||
|
state.setValue(BeltBlock.CASING, segmentTE != null && segmentTE.casing != CasingType.NONE));
|
||||||
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3 | BlockFlags.IS_MOVING);
|
||||||
|
world.removeBlockEntity(pos);
|
||||||
|
world.levelEvent(2001, pos, Block.getId(state));
|
||||||
|
|
||||||
|
if (!creative && AllBlocks.BELT.has(replacedState)
|
||||||
|
&& replacedState.getValue(BeltBlock.PART) == BeltPart.PULLEY)
|
||||||
|
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack());
|
||||||
|
|
||||||
|
// Eject overshooting items
|
||||||
|
if (part == BeltPart.END && inventory != null) {
|
||||||
|
List<TransportedItemStack> toEject = new ArrayList<>();
|
||||||
|
for (TransportedItemStack transportedItemStack : inventory.getTransportedItems())
|
||||||
|
if (transportedItemStack.beltPosition > beltLength - 1)
|
||||||
|
toEject.add(transportedItemStack);
|
||||||
|
toEject.forEach(inventory::eject);
|
||||||
|
toEject.forEach(inventory.getTransportedItems()::remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer items to new controller
|
||||||
|
if (part == BeltPart.START && segmentTE != null && inventory != null) {
|
||||||
|
controllerTE.inventory = null;
|
||||||
|
segmentTE.inventory = null;
|
||||||
|
segmentTE.setController(next);
|
||||||
|
for (TransportedItemStack transportedItemStack : inventory.getTransportedItems()) {
|
||||||
|
transportedItemStack.beltPosition -= 1;
|
||||||
|
if (transportedItemStack.beltPosition <= 0) {
|
||||||
|
ItemEntity entity = new ItemEntity(world, pos.getX() + .5f, pos.getY() + 11 / 16f,
|
||||||
|
pos.getZ() + .5f, transportedItemStack.stack);
|
||||||
|
entity.setDeltaMovement(Vector3d.ZERO);
|
||||||
|
entity.setDefaultPickUpDelay();
|
||||||
|
entity.hurtMarked = true;
|
||||||
|
world.addFreshEntity(entity);
|
||||||
|
} else
|
||||||
|
segmentTE.getInventory()
|
||||||
|
.addItem(transportedItemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeltTileEntity segmentTE = BeltHelper.getSegmentTE(world, pos);
|
||||||
|
if (segmentTE == null)
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
|
// Split in half
|
||||||
|
int hitSegment = segmentTE.index;
|
||||||
|
Vector3d centerOf = VecHelper.getCenterOf(hit.getBlockPos());
|
||||||
|
Vector3d subtract = hit.getLocation()
|
||||||
|
.subtract(centerOf);
|
||||||
|
boolean towardPositive = subtract.dot(Vector3d.atLowerCornerOf(beltVector)) > 0;
|
||||||
|
BlockPos next = !towardPositive ? pos.subtract(beltVector) : pos.offset(beltVector);
|
||||||
|
|
||||||
|
if (hitSegment == 0 || hitSegment == 1 && !towardPositive)
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
if (hitSegment == controllerTE.beltLength - 1 || hitSegment == controllerTE.beltLength - 2 && towardPositive)
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
// Look for shafts
|
||||||
|
if (!creative) {
|
||||||
|
int requiredShafts = 0;
|
||||||
|
if (!segmentTE.hasPulley())
|
||||||
|
requiredShafts++;
|
||||||
|
BlockState other = world.getBlockState(next);
|
||||||
|
if (AllBlocks.BELT.has(other) && other.getValue(BeltBlock.PART) == BeltPart.MIDDLE)
|
||||||
|
requiredShafts++;
|
||||||
|
|
||||||
|
int amountRetrieved = 0;
|
||||||
|
Search: while (true) {
|
||||||
|
for (int i = 0; i < player.inventory.getContainerSize(); ++i) {
|
||||||
|
if (amountRetrieved == requiredShafts)
|
||||||
|
break Search;
|
||||||
|
|
||||||
|
ItemStack itemstack = player.inventory.getItem(i);
|
||||||
|
if (itemstack.isEmpty())
|
||||||
|
continue;
|
||||||
|
int count = itemstack.getCount();
|
||||||
|
if (AllBlocks.SHAFT.isIn(itemstack)) {
|
||||||
|
int taken = Math.min(count, requiredShafts - amountRetrieved);
|
||||||
|
if (taken == count)
|
||||||
|
player.inventory.setItem(i, ItemStack.EMPTY);
|
||||||
|
else
|
||||||
|
itemstack.shrink(taken);
|
||||||
|
amountRetrieved += taken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(amountRetrieved));
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
for (BlockPos blockPos : beltChain) {
|
||||||
|
BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos);
|
||||||
|
if (belt == null)
|
||||||
|
continue;
|
||||||
|
belt.detachKinetics();
|
||||||
|
belt.invalidateItemHandler();
|
||||||
|
belt.beltLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeltInventory inventory = controllerTE.inventory;
|
||||||
|
KineticTileEntity.switchToBlockState(world, pos,
|
||||||
|
state.setValue(BeltBlock.PART, towardPositive ? BeltPart.END : BeltPart.START));
|
||||||
|
KineticTileEntity.switchToBlockState(world, next, world.getBlockState(next)
|
||||||
|
.setValue(BeltBlock.PART, towardPositive ? BeltPart.START : BeltPart.END));
|
||||||
|
world.playSound(null, pos, SoundEvents.WOOL_HIT,
|
||||||
|
player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 0.5F, 2.3F);
|
||||||
|
|
||||||
|
// Transfer items to new controller
|
||||||
|
BeltTileEntity newController = towardPositive ? BeltHelper.getSegmentTE(world, next) : segmentTE;
|
||||||
|
if (newController != null && inventory != null) {
|
||||||
|
newController.inventory = null;
|
||||||
|
newController.setController(newController.getBlockPos());
|
||||||
|
for (Iterator<TransportedItemStack> iterator = inventory.getTransportedItems()
|
||||||
|
.iterator(); iterator.hasNext();) {
|
||||||
|
TransportedItemStack transportedItemStack = iterator.next();
|
||||||
|
float newPosition = transportedItemStack.beltPosition - hitSegment - (towardPositive ? 1 : 0);
|
||||||
|
if (newPosition <= 0)
|
||||||
|
continue;
|
||||||
|
transportedItemStack.beltPosition = newPosition;
|
||||||
|
iterator.remove();
|
||||||
|
newController.getInventory()
|
||||||
|
.addItem(transportedItemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ActionResultType useConnector(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||||
|
Hand handIn, BlockRayTraceResult hit, Feedback feedBack) {
|
||||||
|
BeltTileEntity controllerTE = BeltHelper.getControllerTE(world, pos);
|
||||||
|
if (controllerTE == null)
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
|
int beltLength = controllerTE.beltLength;
|
||||||
|
if (beltLength == BeltConnectorItem.maxLength())
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
BlockPos beltVector = new BlockPos(BeltHelper.getBeltVector(state));
|
||||||
|
BeltPart part = state.getValue(BeltBlock.PART);
|
||||||
|
Direction facing = state.getValue(BeltBlock.HORIZONTAL_FACING);
|
||||||
|
List<BlockPos> beltChain = BeltBlock.getBeltChain(world, controllerTE.getBlockPos());
|
||||||
|
boolean creative = player.isCreative();
|
||||||
|
|
||||||
|
if (!hoveringEnd(state, hit))
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
|
BlockPos next = part == BeltPart.START ? pos.subtract(beltVector) : pos.offset(beltVector);
|
||||||
|
BeltTileEntity mergedController = null;
|
||||||
|
int mergedBeltLength = 0;
|
||||||
|
|
||||||
|
// Merge Belts / Extend at End
|
||||||
|
BlockState nextState = world.getBlockState(next);
|
||||||
|
if (!nextState.getMaterial()
|
||||||
|
.isReplaceable()) {
|
||||||
|
if (!AllBlocks.BELT.has(nextState))
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
if (!beltStatesCompatible(state, nextState))
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
mergedController = BeltHelper.getControllerTE(world, next);
|
||||||
|
if (mergedController == null)
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
if (mergedController.beltLength + beltLength > BeltConnectorItem.maxLength())
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
mergedBeltLength = mergedController.beltLength;
|
||||||
|
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
boolean flipBelt = facing != nextState.getValue(BeltBlock.HORIZONTAL_FACING);
|
||||||
|
Optional<DyeColor> color = controllerTE.color;
|
||||||
|
for (BlockPos blockPos : BeltBlock.getBeltChain(world, mergedController.getBlockPos())) {
|
||||||
|
BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos);
|
||||||
|
if (belt == null)
|
||||||
|
continue;
|
||||||
|
belt.detachKinetics();
|
||||||
|
belt.invalidateItemHandler();
|
||||||
|
belt.beltLength = 0;
|
||||||
|
belt.color = color;
|
||||||
|
if (flipBelt)
|
||||||
|
world.setBlock(blockPos, flipBelt(world.getBlockState(blockPos)), 3 | BlockFlags.IS_MOVING);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse items
|
||||||
|
if (flipBelt && mergedController.inventory != null) {
|
||||||
|
List<TransportedItemStack> transportedItems = mergedController.inventory.getTransportedItems();
|
||||||
|
for (TransportedItemStack transportedItemStack : transportedItems) {
|
||||||
|
transportedItemStack.beltPosition = mergedBeltLength - transportedItemStack.beltPosition;
|
||||||
|
transportedItemStack.prevBeltPosition =
|
||||||
|
mergedBeltLength - transportedItemStack.prevBeltPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
for (BlockPos blockPos : beltChain) {
|
||||||
|
BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos);
|
||||||
|
if (belt == null)
|
||||||
|
continue;
|
||||||
|
belt.detachKinetics();
|
||||||
|
belt.invalidateItemHandler();
|
||||||
|
belt.beltLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeltInventory inventory = controllerTE.inventory;
|
||||||
|
KineticTileEntity.switchToBlockState(world, pos, state.setValue(BeltBlock.PART, BeltPart.MIDDLE));
|
||||||
|
|
||||||
|
if (mergedController == null) {
|
||||||
|
// Attach at end
|
||||||
|
world.setBlock(next, state.setValue(BeltBlock.CASING, false), 3 | BlockFlags.IS_MOVING);
|
||||||
|
BeltTileEntity segmentTE = BeltHelper.getSegmentTE(world, next);
|
||||||
|
if (segmentTE != null)
|
||||||
|
segmentTE.color = controllerTE.color;
|
||||||
|
world.playSound(null, pos, SoundEvents.WOOL_PLACE,
|
||||||
|
player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 0.5F, 1F);
|
||||||
|
|
||||||
|
// Transfer items to new controller
|
||||||
|
if (part == BeltPart.START && segmentTE != null && inventory != null) {
|
||||||
|
segmentTE.setController(next);
|
||||||
|
for (TransportedItemStack transportedItemStack : inventory.getTransportedItems()) {
|
||||||
|
transportedItemStack.beltPosition += 1;
|
||||||
|
segmentTE.getInventory()
|
||||||
|
.addItem(transportedItemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Merge with other
|
||||||
|
BeltInventory mergedInventory = mergedController.inventory;
|
||||||
|
world.playSound(null, pos, SoundEvents.WOOL_HIT,
|
||||||
|
player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 0.5F, 1.3F);
|
||||||
|
BeltTileEntity segmentTE = BeltHelper.getSegmentTE(world, next);
|
||||||
|
KineticTileEntity.switchToBlockState(world, next,
|
||||||
|
state.setValue(BeltBlock.CASING, segmentTE != null && segmentTE.casing != CasingType.NONE)
|
||||||
|
.setValue(BeltBlock.PART, BeltPart.MIDDLE));
|
||||||
|
|
||||||
|
if (!creative)
|
||||||
|
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(2));
|
||||||
|
|
||||||
|
// Transfer items to other controller
|
||||||
|
BlockPos search = controllerTE.getBlockPos();
|
||||||
|
for (int i = 0; i < 10000; i++) {
|
||||||
|
BlockState blockState = world.getBlockState(search);
|
||||||
|
if (!AllBlocks.BELT.has(blockState))
|
||||||
|
break;
|
||||||
|
if (blockState.getValue(BeltBlock.PART) != BeltPart.START) {
|
||||||
|
search = search.subtract(beltVector);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeltTileEntity newController = BeltHelper.getSegmentTE(world, search);
|
||||||
|
|
||||||
|
if (newController != controllerTE && inventory != null) {
|
||||||
|
newController.setController(search);
|
||||||
|
controllerTE.inventory = null;
|
||||||
|
for (TransportedItemStack transportedItemStack : inventory.getTransportedItems()) {
|
||||||
|
transportedItemStack.beltPosition += mergedBeltLength;
|
||||||
|
newController.getInventory()
|
||||||
|
.addItem(transportedItemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newController != mergedController && mergedInventory != null) {
|
||||||
|
newController.setController(search);
|
||||||
|
mergedController.inventory = null;
|
||||||
|
for (TransportedItemStack transportedItemStack : mergedInventory.getTransportedItems()) {
|
||||||
|
if (newController == controllerTE)
|
||||||
|
transportedItemStack.beltPosition += beltLength;
|
||||||
|
newController.getInventory()
|
||||||
|
.addItem(transportedItemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean beltStatesCompatible(BlockState state, BlockState nextState) {
|
||||||
|
Direction facing1 = state.getValue(BeltBlock.HORIZONTAL_FACING);
|
||||||
|
BeltSlope slope1 = state.getValue(BeltBlock.SLOPE);
|
||||||
|
Direction facing2 = nextState.getValue(BeltBlock.HORIZONTAL_FACING);
|
||||||
|
BeltSlope slope2 = nextState.getValue(BeltBlock.SLOPE);
|
||||||
|
|
||||||
|
switch (slope1) {
|
||||||
|
case UPWARD:
|
||||||
|
if (slope2 == BeltSlope.DOWNWARD)
|
||||||
|
return facing1 == facing2.getOpposite();
|
||||||
|
return slope2 == slope1 && facing1 == facing2;
|
||||||
|
case DOWNWARD:
|
||||||
|
if (slope2 == BeltSlope.UPWARD)
|
||||||
|
return facing1 == facing2.getOpposite();
|
||||||
|
return slope2 == slope1 && facing1 == facing2;
|
||||||
|
default:
|
||||||
|
return slope2 == slope1 && facing2.getAxis() == facing1.getAxis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockState flipBelt(BlockState state) {
|
||||||
|
Direction facing = state.getValue(BeltBlock.HORIZONTAL_FACING);
|
||||||
|
BeltSlope slope = state.getValue(BeltBlock.SLOPE);
|
||||||
|
BeltPart part = state.getValue(BeltBlock.PART);
|
||||||
|
|
||||||
|
if (slope == BeltSlope.UPWARD)
|
||||||
|
state = state.setValue(BeltBlock.SLOPE, BeltSlope.DOWNWARD);
|
||||||
|
else if (slope == BeltSlope.DOWNWARD)
|
||||||
|
state = state.setValue(BeltBlock.SLOPE, BeltSlope.UPWARD);
|
||||||
|
|
||||||
|
if (part == BeltPart.END)
|
||||||
|
state = state.setValue(BeltBlock.PART, BeltPart.START);
|
||||||
|
else if (part == BeltPart.START)
|
||||||
|
state = state.setValue(BeltBlock.PART, BeltPart.END);
|
||||||
|
|
||||||
|
return state.setValue(BeltBlock.HORIZONTAL_FACING, facing.getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hoveringEnd(BlockState state, BlockRayTraceResult hit) {
|
||||||
|
BeltPart part = state.getValue(BeltBlock.PART);
|
||||||
|
if (part == BeltPart.MIDDLE || part == BeltPart.PULLEY)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Vector3d beltVector = BeltHelper.getBeltVector(state);
|
||||||
|
Vector3d centerOf = VecHelper.getCenterOf(hit.getBlockPos());
|
||||||
|
Vector3d subtract = hit.getLocation()
|
||||||
|
.subtract(centerOf);
|
||||||
|
|
||||||
|
return subtract.dot(beltVector) > 0 == (part == BeltPart.END);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static void tickHoveringInformation() {
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
RayTraceResult target = mc.hitResult;
|
||||||
|
if (target == null || !(target instanceof BlockRayTraceResult))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BlockRayTraceResult result = (BlockRayTraceResult) target;
|
||||||
|
ClientWorld world = mc.level;
|
||||||
|
BlockPos pos = result.getBlockPos();
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
ItemStack held = mc.player.getItemInHand(Hand.MAIN_HAND);
|
||||||
|
ItemStack heldOffHand = mc.player.getItemInHand(Hand.OFF_HAND);
|
||||||
|
|
||||||
|
if (mc.player.isShiftKeyDown())
|
||||||
|
return;
|
||||||
|
if (!AllBlocks.BELT.has(state))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Feedback feedback = new Feedback();
|
||||||
|
|
||||||
|
// TODO: Populate feedback in the methods for clientside
|
||||||
|
if (AllItems.WRENCH.isIn(held) || AllItems.WRENCH.isIn(heldOffHand))
|
||||||
|
useWrench(state, world, pos, mc.player, Hand.MAIN_HAND, result, feedback);
|
||||||
|
else if (AllItems.BELT_CONNECTOR.isIn(held) || AllItems.BELT_CONNECTOR.isIn(heldOffHand))
|
||||||
|
useConnector(state, world, pos, mc.player, Hand.MAIN_HAND, result, feedback);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (feedback.langKey != null)
|
||||||
|
mc.player.displayClientMessage(Lang.translate(feedback.langKey)
|
||||||
|
.withStyle(feedback.formatting), true);
|
||||||
|
else
|
||||||
|
mc.player.displayClientMessage(new StringTextComponent(""), true);
|
||||||
|
|
||||||
|
if (feedback.bb != null)
|
||||||
|
CreateClient.OUTLINER.chaseAABB("BeltSlicer", feedback.bb)
|
||||||
|
.lineWidth(1 / 16f)
|
||||||
|
.colored(feedback.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -225,8 +225,15 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
||||||
if (!isController())
|
if (!isController())
|
||||||
controller = NBTUtil.readBlockPos(compound.getCompound("Controller"));
|
controller = NBTUtil.readBlockPos(compound.getCompound("Controller"));
|
||||||
trackerUpdateTag = compound;
|
trackerUpdateTag = compound;
|
||||||
beltLength = compound.getInt("Length");
|
|
||||||
index = compound.getInt("Index");
|
index = compound.getInt("Index");
|
||||||
|
int length = compound.getInt("Length");
|
||||||
|
if (beltLength != length) {
|
||||||
|
beltLength = length;
|
||||||
|
if (level != null)
|
||||||
|
initializeLight();
|
||||||
|
else
|
||||||
|
light = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isController())
|
if (isController())
|
||||||
|
@ -519,6 +526,10 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void invalidateItemHandler() {
|
||||||
|
itemHandler.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRenderNormally() {
|
public boolean shouldRenderNormally() {
|
||||||
if (level == null)
|
if (level == null)
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.simibubi.create.content.contraptions.relays.elementary.AbstractShaftB
|
||||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -31,6 +32,8 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -118,6 +121,8 @@ public class BeltConnectorItem extends BlockItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createBelts(World world, BlockPos start, BlockPos end) {
|
public static void createBelts(World world, BlockPos start, BlockPos end) {
|
||||||
|
world.playSound(null, new BlockPos(VecHelper.getCenterOf(start.offset(end))
|
||||||
|
.scale(.5f)), SoundEvents.WOOL_PLACE, SoundCategory.BLOCKS, 0.5F, 1F);
|
||||||
|
|
||||||
BeltSlope slope = getSlopeBetween(start, end);
|
BeltSlope slope = getSlopeBetween(start, end);
|
||||||
Direction facing = getFacingFromTo(start, end);
|
Direction facing = getFacingFromTo(start, end);
|
||||||
|
@ -152,8 +157,8 @@ public class BeltConnectorItem extends BlockItem {
|
||||||
if (diff.getX() == 0 && diff.getZ() == 0)
|
if (diff.getX() == 0 && diff.getZ() == 0)
|
||||||
axisDirection = diff.getY() > 0 ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE;
|
axisDirection = diff.getY() > 0 ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE;
|
||||||
else
|
else
|
||||||
axisDirection = beltAxis.choose(diff.getX(), 0, diff.getZ()) > 0 ? AxisDirection.POSITIVE
|
axisDirection =
|
||||||
: AxisDirection.NEGATIVE;
|
beltAxis.choose(diff.getX(), 0, diff.getZ()) > 0 ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE;
|
||||||
|
|
||||||
return Direction.get(axisDirection, beltAxis);
|
return Direction.get(axisDirection, beltAxis);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +174,8 @@ public class BeltConnectorItem extends BlockItem {
|
||||||
return BeltSlope.HORIZONTAL;
|
return BeltSlope.HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<BlockPos> getBeltChainBetween(BlockPos start, BlockPos end, BeltSlope slope, Direction direction) {
|
private static List<BlockPos> getBeltChainBetween(BlockPos start, BlockPos end, BeltSlope slope,
|
||||||
|
Direction direction) {
|
||||||
List<BlockPos> positions = new LinkedList<>();
|
List<BlockPos> positions = new LinkedList<>();
|
||||||
int limit = 1000;
|
int limit = 1000;
|
||||||
BlockPos current = start;
|
BlockPos current = start;
|
||||||
|
@ -249,7 +255,7 @@ public class BeltConnectorItem extends BlockItem {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Integer maxLength() {
|
public static Integer maxLength() {
|
||||||
return AllConfigs.SERVER.kinetics.maxBeltLength.get();
|
return AllConfigs.SERVER.kinetics.maxBeltLength.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,22 @@ package com.simibubi.create.content.curiosities;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||||
|
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.config.CRecipes;
|
import com.simibubi.create.foundation.config.CRecipes;
|
||||||
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
|
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
|
||||||
|
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
|
||||||
import com.simibubi.create.foundation.utility.Color;
|
import com.simibubi.create.foundation.utility.Color;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
@ -159,6 +166,50 @@ public class ChromaticCompoundItem extends Item {
|
||||||
|
|
||||||
BlockPos randomOffset = new BlockPos(VecHelper.offsetRandomly(positionVec, r, range));
|
BlockPos randomOffset = new BlockPos(VecHelper.offsetRandomly(positionVec, r, range));
|
||||||
BlockState state = world.getBlockState(randomOffset);
|
BlockState state = world.getBlockState(randomOffset);
|
||||||
|
|
||||||
|
TransportedItemStackHandlerBehaviour behaviour =
|
||||||
|
TileEntityBehaviour.get(world, randomOffset, TransportedItemStackHandlerBehaviour.TYPE);
|
||||||
|
|
||||||
|
// Find a placed light source
|
||||||
|
if (behaviour == null) {
|
||||||
|
if (checkLight(stack, entity, world, itemData, positionVec, randomOffset, state))
|
||||||
|
world.destroyBlock(randomOffset, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find a light source from a depot/belt (chunk rebuild safe)
|
||||||
|
MutableBoolean success = new MutableBoolean(false);
|
||||||
|
behaviour.handleProcessingOnAllItems(ts -> {
|
||||||
|
|
||||||
|
ItemStack heldStack = ts.stack;
|
||||||
|
if (!(heldStack.getItem() instanceof BlockItem))
|
||||||
|
return TransportedResult.doNothing();
|
||||||
|
|
||||||
|
BlockItem blockItem = (BlockItem) heldStack.getItem();
|
||||||
|
if (blockItem.getBlock() == null)
|
||||||
|
return TransportedResult.doNothing();
|
||||||
|
|
||||||
|
BlockState stateToCheck = blockItem.getBlock()
|
||||||
|
.defaultBlockState();
|
||||||
|
|
||||||
|
if (!success.getValue()
|
||||||
|
&& checkLight(stack, entity, world, itemData, positionVec, randomOffset, stateToCheck)) {
|
||||||
|
success.setTrue();
|
||||||
|
if (ts.stack.getCount() == 1)
|
||||||
|
return TransportedResult.removeItem();
|
||||||
|
TransportedItemStack left = ts.copy();
|
||||||
|
left.stack.shrink(1);
|
||||||
|
return TransportedResult.convertTo(left);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TransportedResult.doNothing();
|
||||||
|
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkLight(ItemStack stack, ItemEntity entity, World world, CompoundNBT itemData,
|
||||||
|
Vector3d positionVec, BlockPos randomOffset, BlockState state) {
|
||||||
if (state.getLightValue(world, randomOffset) == 0)
|
if (state.getLightValue(world, randomOffset) == 0)
|
||||||
return false;
|
return false;
|
||||||
if (state.getDestroySpeed(world, randomOffset) == -1)
|
if (state.getDestroySpeed(world, randomOffset) == -1)
|
||||||
|
@ -166,14 +217,12 @@ public class ChromaticCompoundItem extends Item {
|
||||||
if (state.getBlock() == Blocks.BEACON)
|
if (state.getBlock() == Blocks.BEACON)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
RayTraceContext context = new RayTraceContext(positionVec, VecHelper.getCenterOf(randomOffset),
|
RayTraceContext context = new RayTraceContext(positionVec.add(new Vector3d(0, 0.5, 0)),
|
||||||
BlockMode.COLLIDER, FluidMode.NONE, entity);
|
VecHelper.getCenterOf(randomOffset), BlockMode.COLLIDER, FluidMode.NONE, entity);
|
||||||
if (!randomOffset.equals(world.clip(context)
|
if (!randomOffset.equals(world.clip(context)
|
||||||
.getBlockPos()))
|
.getBlockPos()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
world.destroyBlock(randomOffset, false);
|
|
||||||
|
|
||||||
ItemStack newStack = stack.split(1);
|
ItemStack newStack = stack.split(1);
|
||||||
newStack.getOrCreateTag()
|
newStack.getOrCreateTag()
|
||||||
.putInt("CollectingLight", itemData.getInt("CollectingLight") + 1);
|
.putInt("CollectingLight", itemData.getInt("CollectingLight") + 1);
|
||||||
|
@ -184,8 +233,7 @@ public class ChromaticCompoundItem extends Item {
|
||||||
entity.lifespan = 6000;
|
entity.lifespan = 6000;
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class RefinedRadianceItem extends NoGravMagicalDohickyItem {
|
||||||
protected void onCreated(ItemEntity entity, CompoundNBT persistentData) {
|
protected void onCreated(ItemEntity entity, CompoundNBT persistentData) {
|
||||||
super.onCreated(entity, persistentData);
|
super.onCreated(entity, persistentData);
|
||||||
entity.setDeltaMovement(entity.getDeltaMovement()
|
entity.setDeltaMovement(entity.getDeltaMovement()
|
||||||
.add(0, .15f, 0));
|
.add(0, .25f, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.simibubi.create.content.contraptions.components.turntable.TurntableHa
|
||||||
import com.simibubi.create.content.contraptions.goggles.GoggleOverlayRenderer;
|
import com.simibubi.create.content.contraptions.goggles.GoggleOverlayRenderer;
|
||||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||||
import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe;
|
import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.BeltSlicer;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
|
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
|
||||||
import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer;
|
import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer;
|
||||||
import com.simibubi.create.content.curiosities.tools.BlueprintOverlayRenderer;
|
import com.simibubi.create.content.curiosities.tools.BlueprintOverlayRenderer;
|
||||||
|
@ -125,6 +126,7 @@ public class ClientEvents {
|
||||||
// ScreenOpener.tick();
|
// ScreenOpener.tick();
|
||||||
ServerSpeedProvider.clientTick();
|
ServerSpeedProvider.clientTick();
|
||||||
BeltConnectorHandler.tick();
|
BeltConnectorHandler.tick();
|
||||||
|
BeltSlicer.tickHoveringInformation();
|
||||||
FilteringRenderer.tick();
|
FilteringRenderer.tick();
|
||||||
LinkRenderer.tick();
|
LinkRenderer.tick();
|
||||||
ScrollValueRenderer.tick();
|
ScrollValueRenderer.tick();
|
||||||
|
|
|
@ -30,10 +30,12 @@ public class MechanicalCraftingRecipeBuilder {
|
||||||
private final int count;
|
private final int count;
|
||||||
private final List<String> pattern = Lists.newArrayList();
|
private final List<String> pattern = Lists.newArrayList();
|
||||||
private final Map<Character, Ingredient> key = Maps.newLinkedHashMap();
|
private final Map<Character, Ingredient> key = Maps.newLinkedHashMap();
|
||||||
|
private boolean acceptMirrored;
|
||||||
|
|
||||||
public MechanicalCraftingRecipeBuilder(IItemProvider p_i48261_1_, int p_i48261_2_) {
|
public MechanicalCraftingRecipeBuilder(IItemProvider p_i48261_1_, int p_i48261_2_) {
|
||||||
result = p_i48261_1_.asItem();
|
result = p_i48261_1_.asItem();
|
||||||
count = p_i48261_2_;
|
count = p_i48261_2_;
|
||||||
|
acceptMirrored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,6 +93,14 @@ public class MechanicalCraftingRecipeBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevents the crafters from matching a vertically flipped version of the recipe
|
||||||
|
*/
|
||||||
|
public MechanicalCraftingRecipeBuilder disallowMirrored() {
|
||||||
|
acceptMirrored = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds this recipe into an {@link IFinishedRecipe}.
|
* Builds this recipe into an {@link IFinishedRecipe}.
|
||||||
*/
|
*/
|
||||||
|
@ -116,7 +126,8 @@ public class MechanicalCraftingRecipeBuilder {
|
||||||
*/
|
*/
|
||||||
public void build(Consumer<IFinishedRecipe> p_200467_1_, ResourceLocation p_200467_2_) {
|
public void build(Consumer<IFinishedRecipe> p_200467_1_, ResourceLocation p_200467_2_) {
|
||||||
validate(p_200467_2_);
|
validate(p_200467_2_);
|
||||||
p_200467_1_.accept(new MechanicalCraftingRecipeBuilder.Result(p_200467_2_, result, count, pattern, key));
|
p_200467_1_
|
||||||
|
.accept(new MechanicalCraftingRecipeBuilder.Result(p_200467_2_, result, count, pattern, key, acceptMirrored));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,14 +162,16 @@ public class MechanicalCraftingRecipeBuilder {
|
||||||
private final int count;
|
private final int count;
|
||||||
private final List<String> pattern;
|
private final List<String> pattern;
|
||||||
private final Map<Character, Ingredient> key;
|
private final Map<Character, Ingredient> key;
|
||||||
|
private final boolean acceptMirrored;
|
||||||
|
|
||||||
public Result(ResourceLocation p_i48271_2_, Item p_i48271_3_, int p_i48271_4_, List<String> p_i48271_6_,
|
public Result(ResourceLocation p_i48271_2_, Item p_i48271_3_, int p_i48271_4_, List<String> p_i48271_6_,
|
||||||
Map<Character, Ingredient> p_i48271_7_) {
|
Map<Character, Ingredient> p_i48271_7_, boolean asymmetrical) {
|
||||||
this.id = p_i48271_2_;
|
this.id = p_i48271_2_;
|
||||||
this.result = p_i48271_3_;
|
this.result = p_i48271_3_;
|
||||||
this.count = p_i48271_4_;
|
this.count = p_i48271_4_;
|
||||||
this.pattern = p_i48271_6_;
|
this.pattern = p_i48271_6_;
|
||||||
this.key = p_i48271_7_;
|
this.key = p_i48271_7_;
|
||||||
|
this.acceptMirrored = asymmetrical;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serializeRecipeData(JsonObject p_218610_1_) {
|
public void serializeRecipeData(JsonObject p_218610_1_) {
|
||||||
|
@ -180,6 +193,7 @@ public class MechanicalCraftingRecipeBuilder {
|
||||||
jsonobject1.addProperty("count", this.count);
|
jsonobject1.addProperty("count", this.count);
|
||||||
|
|
||||||
p_218610_1_.add("result", jsonobject1);
|
p_218610_1_.add("result", jsonobject1);
|
||||||
|
p_218610_1_.addProperty("acceptMirrored", acceptMirrored);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRecipeSerializer<?> getType() {
|
public IRecipeSerializer<?> getType() {
|
||||||
|
|
|
@ -27,7 +27,8 @@ public class MechanicalCraftingRecipeGen extends CreateRecipeProvider {
|
||||||
.patternLine("AAPAA")
|
.patternLine("AAPAA")
|
||||||
.patternLine("APSPA")
|
.patternLine("APSPA")
|
||||||
.patternLine("AAPAA")
|
.patternLine("AAPAA")
|
||||||
.patternLine(" AAA ")),
|
.patternLine(" AAA ")
|
||||||
|
.disallowMirrored()),
|
||||||
|
|
||||||
EXTENDO_GRIP = create(AllItems.EXTENDO_GRIP::get).returns(1)
|
EXTENDO_GRIP = create(AllItems.EXTENDO_GRIP::get).returns(1)
|
||||||
.recipe(b -> b.key('L', Ingredient.of(I.brass()))
|
.recipe(b -> b.key('L', Ingredient.of(I.brass()))
|
||||||
|
@ -38,7 +39,8 @@ public class MechanicalCraftingRecipeGen extends CreateRecipeProvider {
|
||||||
.patternLine(" R ")
|
.patternLine(" R ")
|
||||||
.patternLine("SSS")
|
.patternLine("SSS")
|
||||||
.patternLine("SSS")
|
.patternLine("SSS")
|
||||||
.patternLine(" H ")),
|
.patternLine(" H ")
|
||||||
|
.disallowMirrored()),
|
||||||
|
|
||||||
POTATO_CANNON = create(AllItems.POTATO_CANNON::get).returns(1)
|
POTATO_CANNON = create(AllItems.POTATO_CANNON::get).returns(1)
|
||||||
.recipe(b -> b.key('L', I.andesite())
|
.recipe(b -> b.key('L', I.andesite())
|
||||||
|
|
|
@ -52,6 +52,8 @@ import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
import net.minecraft.util.math.vector.Vector4f;
|
import net.minecraft.util.math.vector.Vector4f;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class PonderScene {
|
public class PonderScene {
|
||||||
|
|
||||||
public static final String TITLE_KEY = "header";
|
public static final String TITLE_KEY = "header";
|
||||||
|
@ -79,6 +81,7 @@ public class PonderScene {
|
||||||
Vector3d pointOfInterest;
|
Vector3d pointOfInterest;
|
||||||
Vector3d chasingPointOfInterest;
|
Vector3d chasingPointOfInterest;
|
||||||
WorldSectionElement baseWorldSection;
|
WorldSectionElement baseWorldSection;
|
||||||
|
@Nullable
|
||||||
Entity renderViewEntity;
|
Entity renderViewEntity;
|
||||||
|
|
||||||
int basePlateOffsetX;
|
int basePlateOffsetX;
|
||||||
|
@ -112,7 +115,7 @@ public class PonderScene {
|
||||||
basePlateSize = getBounds().getXSpan();
|
basePlateSize = getBounds().getXSpan();
|
||||||
info = new SceneRenderInfo();
|
info = new SceneRenderInfo();
|
||||||
baseWorldSection = new WorldSectionElement();
|
baseWorldSection = new WorldSectionElement();
|
||||||
renderViewEntity = new ArmorStandEntity(world, 0, 0, 0);
|
renderViewEntity = world != null ? new ArmorStandEntity(world, 0, 0, 0) : null;
|
||||||
keyframeTimes = new IntArrayList(4);
|
keyframeTimes = new IntArrayList(4);
|
||||||
scaleFactor = 1;
|
scaleFactor = 1;
|
||||||
yOffset = 0;
|
yOffset = 0;
|
||||||
|
@ -486,7 +489,8 @@ public class PonderScene {
|
||||||
|
|
||||||
public void updateSceneRVE(float pt) {
|
public void updateSceneRVE(float pt) {
|
||||||
Vector3d v = screenToScene(width / 2, height / 2, 500, pt);
|
Vector3d v = screenToScene(width / 2, height / 2, 500, pt);
|
||||||
renderViewEntity.setPos(v.x, v.y, v.z);
|
if (renderViewEntity != null)
|
||||||
|
renderViewEntity.setPos(v.x, v.y, v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3d screenToScene(double x, double y, int depth, float pt) {
|
public Vector3d screenToScene(double x, double y, int depth, float pt) {
|
||||||
|
|
Loading…
Reference in a new issue