mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Merge remote-tracking branch 'refs/remotes/origin/mc1.20.1/feature-dev' into jay/mc1.20.1/attached-registry-refactors
# Conflicts: # src/main/java/com/simibubi/create/content/contraptions/mounted/MinecartContraptionItem.java
This commit is contained in:
commit
0f752d604c
215 changed files with 1695 additions and 1660 deletions
|
@ -1,4 +1,4 @@
|
||||||
// 1.20.1 2025-02-07T14:33:10.4318818 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
|
// 1.20.1 2025-02-12T10:49:57.1047644 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
|
||||||
60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json
|
60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json
|
||||||
6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json
|
6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json
|
||||||
c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json
|
c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json
|
||||||
|
@ -642,8 +642,8 @@ b0d8f08968763a5f74e5cd5644377a76a9f39753 assets/create/blockstates/yellow_toolbo
|
||||||
fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_handle.json
|
fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_handle.json
|
||||||
e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json
|
e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json
|
||||||
64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json
|
64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json
|
||||||
99c03ec65894ea7d88e3346c5e0c086a7acec6af assets/create/lang/en_ud.json
|
443742f2bb4fc520ec7db483fd22425884cb95be assets/create/lang/en_ud.json
|
||||||
5f0262b9f6c1139659f6dab4d9c371be50503c0b assets/create/lang/en_us.json
|
282779fe7ecc64cd99c08e3a7397646af9f500c4 assets/create/lang/en_us.json
|
||||||
a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json
|
a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json
|
||||||
103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json
|
103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json
|
||||||
fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// 1.20.1 2025-02-07T11:36:36.6037564 Create's Standard Recipes
|
// 1.20.1 2025-02-12T10:49:57.1801346 Create's Standard Recipes
|
||||||
a8cc4af26f6c7c45a9eef12e92af1452fe042454 data/create/advancements/recipes/combat/crafting/appliances/netherite_backtank.json
|
a8cc4af26f6c7c45a9eef12e92af1452fe042454 data/create/advancements/recipes/combat/crafting/appliances/netherite_backtank.json
|
||||||
2c2639c7b307ee7c7a4e97e5efebf496788998ad data/create/advancements/recipes/combat/crafting/appliances/netherite_backtank_from_netherite.json
|
2c2639c7b307ee7c7a4e97e5efebf496788998ad data/create/advancements/recipes/combat/crafting/appliances/netherite_backtank_from_netherite.json
|
||||||
81dcf0cb1aa99e39bc7d1a386e07cad4cee7d8b9 data/create/advancements/recipes/combat/crafting/appliances/netherite_diving_boots.json
|
81dcf0cb1aa99e39bc7d1a386e07cad4cee7d8b9 data/create/advancements/recipes/combat/crafting/appliances/netherite_diving_boots.json
|
||||||
|
@ -466,7 +466,7 @@ d994ef262b16357984d3ed62f6563d2f37266193 data/create/recipes/crafting/logistics/
|
||||||
4daadd2c67fe8bbf5594fb50dcf051dad7f9997a data/create/recipes/crafting/logistics/factory_gauge.json
|
4daadd2c67fe8bbf5594fb50dcf051dad7f9997a data/create/recipes/crafting/logistics/factory_gauge.json
|
||||||
2fb7722137990b9b9be967a1f766e138678d0573 data/create/recipes/crafting/logistics/factory_gauge_clear.json
|
2fb7722137990b9b9be967a1f766e138678d0573 data/create/recipes/crafting/logistics/factory_gauge_clear.json
|
||||||
f3ba21e8979256fb78cd618ac4f1082b0b2f9e0c data/create/recipes/crafting/logistics/item_hatch.json
|
f3ba21e8979256fb78cd618ac4f1082b0b2f9e0c data/create/recipes/crafting/logistics/item_hatch.json
|
||||||
38c6236d7ac157a75ac5a98ab9b712eabb0c78c4 data/create/recipes/crafting/logistics/packager.json
|
7d66c3b5d704f583e32617b37620e749462eaa1f data/create/recipes/crafting/logistics/packager.json
|
||||||
6b51fa6a5bd1e9dc8e7387269d985cd622ab8ada data/create/recipes/crafting/logistics/packager_from_conversion.json
|
6b51fa6a5bd1e9dc8e7387269d985cd622ab8ada data/create/recipes/crafting/logistics/packager_from_conversion.json
|
||||||
6852cb8ff6916981920ab9c987c6e357e9236511 data/create/recipes/crafting/logistics/package_frogport.json
|
6852cb8ff6916981920ab9c987c6e357e9236511 data/create/recipes/crafting/logistics/package_frogport.json
|
||||||
dd28b63ceb46a1e9071549c4f8ff32f520c667f6 data/create/recipes/crafting/logistics/powered_latch.json
|
dd28b63ceb46a1e9071549c4f8ff32f520c667f6 data/create/recipes/crafting/logistics/powered_latch.json
|
||||||
|
|
|
@ -1580,6 +1580,7 @@
|
||||||
"create.package_port.cannot_reach_down": "pɹɐʍuʍop ʇɔǝuuoɔ ʇouuɐƆ",
|
"create.package_port.cannot_reach_down": "pɹɐʍuʍop ʇɔǝuuoɔ ʇouuɐƆ",
|
||||||
"create.package_port.too_far": "ʎɐʍɐ ɹɐɟ oo⟘",
|
"create.package_port.too_far": "ʎɐʍɐ ɹɐɟ oo⟘",
|
||||||
"create.package_port.valid": "✔ ʇɔǝuuoƆ uɐƆ",
|
"create.package_port.valid": "✔ ʇɔǝuuoƆ uɐƆ",
|
||||||
|
"create.packager.no_portable_storage": "ʎןʇɔǝɹıp ǝbɐɹoʇS ǝןqɐʇɹoԀ ɥʇıʍ ǝɔɐɟɹǝʇuı ʇouuɐɔ sɹǝbɐʞɔɐԀ",
|
||||||
"create.packager_link.clear": "uoıʇɔǝןǝs pǝɹɐǝןƆ",
|
"create.packager_link.clear": "uoıʇɔǝןǝs pǝɹɐǝןƆ",
|
||||||
"create.packager_link.set": "pǝʇɔǝןǝs ʇǝbɹɐ⟘",
|
"create.packager_link.set": "pǝʇɔǝןǝs ʇǝbɹɐ⟘",
|
||||||
"create.packager_link.success": "ʇǝbɹɐʇ oʇ punoq ʎןןnɟssǝɔɔnS",
|
"create.packager_link.success": "ʇǝbɹɐʇ oʇ punoq ʎןןnɟssǝɔɔnS",
|
||||||
|
|
|
@ -1580,6 +1580,7 @@
|
||||||
"create.package_port.cannot_reach_down": "Cannot connect downward",
|
"create.package_port.cannot_reach_down": "Cannot connect downward",
|
||||||
"create.package_port.too_far": "Too far away",
|
"create.package_port.too_far": "Too far away",
|
||||||
"create.package_port.valid": "Can Connect ✔",
|
"create.package_port.valid": "Can Connect ✔",
|
||||||
|
"create.packager.no_portable_storage": "Packagers cannot interface with Portable Storage directly",
|
||||||
"create.packager_link.clear": "Cleared selection",
|
"create.packager_link.clear": "Cleared selection",
|
||||||
"create.packager_link.set": "Target selected",
|
"create.packager_link.set": "Target selected",
|
||||||
"create.packager_link.success": "Successfully bound to target",
|
"create.packager_link.success": "Successfully bound to target",
|
||||||
|
|
|
@ -7,12 +7,15 @@
|
||||||
},
|
},
|
||||||
"C": {
|
"C": {
|
||||||
"tag": "forge:ingots/iron"
|
"tag": "forge:ingots/iron"
|
||||||
|
},
|
||||||
|
"R": {
|
||||||
|
"tag": "forge:dusts/redstone"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pattern": [
|
"pattern": [
|
||||||
" C ",
|
" C ",
|
||||||
"CAC",
|
"CAC",
|
||||||
" C "
|
"RCR"
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "create:packager"
|
"item": "create:packager"
|
||||||
|
|
|
@ -383,8 +383,7 @@ public class AllBlocks {
|
||||||
|
|
||||||
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
.properties(p -> p.mapColor(MapColor.METAL)
|
.properties(p -> p.mapColor(MapColor.METAL).forceSolidOff())
|
||||||
.forceSolidOn())
|
|
||||||
.transform(BlockStressDefaults.setNoImpact())
|
.transform(BlockStressDefaults.setNoImpact())
|
||||||
.transform(pickaxeOnly())
|
.transform(pickaxeOnly())
|
||||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||||
|
@ -891,7 +890,7 @@ public class AllBlocks {
|
||||||
|
|
||||||
public static final BlockEntry<FluidPipeBlock> FLUID_PIPE = REGISTRATE.block("fluid_pipe", FluidPipeBlock::new)
|
public static final BlockEntry<FluidPipeBlock> FLUID_PIPE = REGISTRATE.block("fluid_pipe", FluidPipeBlock::new)
|
||||||
.initialProperties(SharedProperties::copperMetal)
|
.initialProperties(SharedProperties::copperMetal)
|
||||||
.properties(p -> p.forceSolidOn())
|
.properties(p -> p.forceSolidOff())
|
||||||
.transform(pickaxeOnly())
|
.transform(pickaxeOnly())
|
||||||
.blockstate(BlockStateGen.pipe())
|
.blockstate(BlockStateGen.pipe())
|
||||||
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::withoutAO))
|
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::withoutAO))
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
package com.simibubi.create;
|
package com.simibubi.create;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
||||||
import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType;
|
import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType;
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import net.minecraftforge.registries.NewRegistryEvent;
|
import net.minecraftforge.registries.NewRegistryEvent;
|
||||||
import net.minecraftforge.registries.RegistryBuilder;
|
import net.minecraftforge.registries.RegistryBuilder;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class AllRegistries {
|
public class AllRegistries {
|
||||||
public static Supplier<IForgeRegistry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPES;
|
public static Supplier<IForgeRegistry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPE;
|
||||||
public static Supplier<IForgeRegistry<FanProcessingType>> FAN_PROCESSING_TYPES;
|
public static Supplier<IForgeRegistry<FanProcessingType>> FAN_PROCESSING_TYPE;
|
||||||
public static Supplier<IForgeRegistry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPES;
|
public static Supplier<IForgeRegistry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPE;
|
||||||
|
|
||||||
public static final class Keys {
|
public static final class Keys {
|
||||||
public static final ResourceKey<Registry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPES = key("arm_interaction_point_types");
|
public static final ResourceKey<Registry<ArmInteractionPointType>> ARM_INTERACTION_POINT_TYPE = key("arm_interaction_point_type");
|
||||||
public static final ResourceKey<Registry<FanProcessingType>> FAN_PROCESSING_TYPES = key("fan_processing_types");
|
public static final ResourceKey<Registry<FanProcessingType>> FAN_PROCESSING_TYPE = key("fan_processing_type");
|
||||||
public static final ResourceKey<Registry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPES = key("item_attribute_types");
|
public static final ResourceKey<Registry<ItemAttributeType>> ITEM_ATTRIBUTE_TYPE = key("item_attribute_type");
|
||||||
|
|
||||||
private static <T> ResourceKey<Registry<T>> key(String name) {
|
private static <T> ResourceKey<Registry<T>> key(String name) {
|
||||||
return ResourceKey.createRegistryKey(Create.asResource(name));
|
return ResourceKey.createRegistryKey(Create.asResource(name));
|
||||||
|
@ -32,16 +33,16 @@ public class AllRegistries {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerRegistries(NewRegistryEvent event) {
|
public static void registerRegistries(NewRegistryEvent event) {
|
||||||
ARM_INTERACTION_POINT_TYPES = event.create(new RegistryBuilder<ArmInteractionPointType>()
|
ARM_INTERACTION_POINT_TYPE = event.create(new RegistryBuilder<ArmInteractionPointType>()
|
||||||
.setName(Keys.ARM_INTERACTION_POINT_TYPES.location())
|
.setName(Keys.ARM_INTERACTION_POINT_TYPE.location())
|
||||||
.disableSaving());
|
|
||||||
|
|
||||||
FAN_PROCESSING_TYPES = event.create(new RegistryBuilder<FanProcessingType>()
|
|
||||||
.setName(Keys.FAN_PROCESSING_TYPES.location())
|
|
||||||
.disableSaving());
|
.disableSaving());
|
||||||
|
|
||||||
ITEM_ATTRIBUTE_TYPES = event.create(new RegistryBuilder<ItemAttributeType>()
|
FAN_PROCESSING_TYPE = event.create(new RegistryBuilder<FanProcessingType>()
|
||||||
.setName(Keys.ITEM_ATTRIBUTE_TYPES.location())
|
.setName(Keys.FAN_PROCESSING_TYPE.location())
|
||||||
|
.disableSaving());
|
||||||
|
|
||||||
|
ITEM_ATTRIBUTE_TYPE = event.create(new RegistryBuilder<ItemAttributeType>()
|
||||||
|
.setName(Keys.ITEM_ATTRIBUTE_TYPE.location())
|
||||||
.disableSaving());
|
.disableSaving());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -8,7 +10,11 @@ import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlockEntity;
|
||||||
import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext;
|
import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext;
|
||||||
import com.simibubi.create.content.redstone.displayLink.target.DisplayTargetStats;
|
import com.simibubi.create.content.redstone.displayLink.target.DisplayTargetStats;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.lua.IArguments;
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
import dan200.computercraft.api.lua.LuaFunction;
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
|
import dan200.computercraft.api.lua.LuaValues;
|
||||||
|
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.StringTag;
|
import net.minecraft.nbt.StringTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
|
@ -53,6 +59,28 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
|
||||||
|
|
||||||
@LuaFunction
|
@LuaFunction
|
||||||
public final void write(String text) {
|
public final void write(String text) {
|
||||||
|
writeImpl(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final void writeBytes(IArguments args) throws LuaException {
|
||||||
|
Object data = args.get(0);
|
||||||
|
byte[] bytes;
|
||||||
|
if (data instanceof String str) {
|
||||||
|
bytes = str.getBytes(StandardCharsets.US_ASCII);
|
||||||
|
} else if (data instanceof Map<?, ?> map) {
|
||||||
|
ObjectLuaTable table = new ObjectLuaTable(map);
|
||||||
|
bytes = new byte[table.length()];
|
||||||
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
|
bytes[i] = (byte) (table.getInt(i + 1) & 0xff);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw LuaValues.badArgumentOf(args, 0, "string or table");
|
||||||
|
}
|
||||||
|
writeImpl(new String(bytes, StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void writeImpl(String text) {
|
||||||
ListTag tag = blockEntity.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
|
ListTag tag = blockEntity.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING);
|
||||||
|
|
||||||
int x = cursorX.get();
|
int x = cursorX.get();
|
||||||
|
|
|
@ -243,8 +243,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
|
|
||||||
Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat)
|
Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat)
|
||||||
.add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks)
|
.add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks)
|
||||||
.add(VecHelper.getCenterOf(BlockPos.ZERO))
|
.add(VecHelper.getCenterOf(BlockPos.ZERO))
|
||||||
.subtract(0.5, ySize, 0.5);
|
.subtract(0.5, ySize, 0.5);
|
||||||
return transformedVector;
|
return transformedVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
return true;
|
return true;
|
||||||
return contraption.getSeatMapping()
|
return contraption.getSeatMapping()
|
||||||
.size() < contraption.getSeats()
|
.size() < contraption.getSeats()
|
||||||
.size();
|
.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getContraptionName() {
|
public Component getContraptionName() {
|
||||||
|
@ -286,7 +286,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handlePlayerInteraction(Player player, BlockPos localPos, Direction side,
|
public boolean handlePlayerInteraction(Player player, BlockPos localPos, Direction side,
|
||||||
InteractionHand interactionHand) {
|
InteractionHand interactionHand) {
|
||||||
int indexOfSeat = contraption.getSeats()
|
int indexOfSeat = contraption.getSeats()
|
||||||
.indexOf(localPos);
|
.indexOf(localPos);
|
||||||
if (indexOfSeat == -1 || AllItems.WRENCH.isIn(player.getItemInHand(interactionHand))) {
|
if (indexOfSeat == -1 || AllItems.WRENCH.isIn(player.getItemInHand(interactionHand))) {
|
||||||
|
@ -486,11 +486,10 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
skipActorStop = false;
|
skipActorStop = false;
|
||||||
|
|
||||||
for (Entity entity : getPassengers()) {
|
for (Entity entity : getPassengers()) {
|
||||||
if (!(entity instanceof OrientedContraptionEntity))
|
if (!(entity instanceof OrientedContraptionEntity orientedCE))
|
||||||
continue;
|
continue;
|
||||||
if (!contraption.stabilizedSubContraptions.containsKey(entity.getUUID()))
|
if (!contraption.stabilizedSubContraptions.containsKey(entity.getUUID()))
|
||||||
continue;
|
continue;
|
||||||
OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity;
|
|
||||||
if (orientedCE.contraption != null && orientedCE.contraption.stalled) {
|
if (orientedCE.contraption != null && orientedCE.contraption.stalled) {
|
||||||
contraption.stalled = true;
|
contraption.stalled = true;
|
||||||
break;
|
break;
|
||||||
|
@ -528,7 +527,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor,
|
protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor,
|
||||||
Vec3 actorPosition, BlockPos gridPosition) {
|
Vec3 actorPosition, BlockPos gridPosition) {
|
||||||
Vec3 previousPosition = context.position;
|
Vec3 previousPosition = context.position;
|
||||||
if (previousPosition == null)
|
if (previousPosition == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -730,7 +729,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doWaterSplashEffect() {}
|
protected void doWaterSplashEffect() {
|
||||||
|
}
|
||||||
|
|
||||||
public Contraption getContraption() {
|
public Contraption getContraption() {
|
||||||
return contraption;
|
return contraption;
|
||||||
|
@ -797,7 +797,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// Make sure nothing can move contraptions out of the way
|
// Make sure nothing can move contraptions out of the way
|
||||||
public void setDeltaMovement(Vec3 motionIn) {}
|
public void setDeltaMovement(Vec3 motionIn) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPistonPushReaction() {
|
public PushReaction getPistonPushReaction() {
|
||||||
|
|
|
@ -89,7 +89,6 @@ import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.protocol.game.DebugPackets;
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
|
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
|
||||||
|
@ -101,11 +100,11 @@ import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.ButtonBlock;
|
import net.minecraft.world.level.block.ButtonBlock;
|
||||||
import net.minecraft.world.level.block.ChestBlock;
|
import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.DoorBlock;
|
import net.minecraft.world.level.block.DoorBlock;
|
||||||
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
import net.minecraft.world.level.block.PressurePlateBlock;
|
import net.minecraft.world.level.block.PressurePlateBlock;
|
||||||
import net.minecraft.world.level.block.Rotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.level.block.state.properties.ChestType;
|
import net.minecraft.world.level.block.state.properties.ChestType;
|
||||||
|
@ -206,7 +205,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean addToInitialFrontier(Level world, BlockPos pos, Direction forcedDirection,
|
protected boolean addToInitialFrontier(Level world, BlockPos pos, Direction forcedDirection,
|
||||||
Queue<BlockPos> frontier) throws AssemblyException {
|
Queue<BlockPos> frontier) throws AssemblyException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,9 +296,11 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** move the first block in frontier queue */
|
/**
|
||||||
|
* move the first block in frontier queue
|
||||||
|
*/
|
||||||
protected boolean moveBlock(Level world, @Nullable Direction forcedDirection, Queue<BlockPos> frontier,
|
protected boolean moveBlock(Level world, @Nullable Direction forcedDirection, Queue<BlockPos> frontier,
|
||||||
Set<BlockPos> visited) throws AssemblyException {
|
Set<BlockPos> visited) throws AssemblyException {
|
||||||
BlockPos pos = frontier.poll();
|
BlockPos pos = frontier.poll();
|
||||||
if (pos == null)
|
if (pos == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,7 +324,7 @@ public abstract class Contraption {
|
||||||
if (AllBlocks.BELT.has(state))
|
if (AllBlocks.BELT.has(state))
|
||||||
moveBelt(pos, frontier, visited, state);
|
moveBelt(pos, frontier, visited, state);
|
||||||
|
|
||||||
if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos)instanceof WindmillBearingBlockEntity wbbe)
|
if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos) instanceof WindmillBearingBlockEntity wbbe)
|
||||||
wbbe.disassembleForMovement();
|
wbbe.disassembleForMovement();
|
||||||
|
|
||||||
if (AllBlocks.GANTRY_CARRIAGE.has(state))
|
if (AllBlocks.GANTRY_CARRIAGE.has(state))
|
||||||
|
@ -353,7 +354,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bogeys tend to have sticky sides
|
// Bogeys tend to have sticky sides
|
||||||
if (state.getBlock()instanceof AbstractBogeyBlock<?> bogey)
|
if (state.getBlock() instanceof AbstractBogeyBlock<?> bogey)
|
||||||
for (Direction d : bogey.getStickySurfaces(world, pos, state))
|
for (Direction d : bogey.getStickySurfaces(world, pos, state))
|
||||||
if (!visited.contains(pos.relative(d)))
|
if (!visited.contains(pos.relative(d)))
|
||||||
frontier.add(pos.relative(d));
|
frontier.add(pos.relative(d));
|
||||||
|
@ -433,7 +434,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void movePistonHead(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
protected void movePistonHead(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
||||||
BlockState state) {
|
BlockState state) {
|
||||||
Direction direction = state.getValue(MechanicalPistonHeadBlock.FACING);
|
Direction direction = state.getValue(MechanicalPistonHeadBlock.FACING);
|
||||||
BlockPos offset = pos.relative(direction.getOpposite());
|
BlockPos offset = pos.relative(direction.getOpposite());
|
||||||
if (!visited.contains(offset)) {
|
if (!visited.contains(offset)) {
|
||||||
|
@ -456,7 +457,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void movePistonPole(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
protected void movePistonPole(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
||||||
BlockState state) {
|
BlockState state) {
|
||||||
for (Direction d : Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING)
|
for (Direction d : Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING)
|
||||||
.getAxis())) {
|
.getAxis())) {
|
||||||
BlockPos offset = pos.relative(d);
|
BlockPos offset = pos.relative(d);
|
||||||
|
@ -479,7 +480,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveGantryPinion(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
protected void moveGantryPinion(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
||||||
BlockState state) {
|
BlockState state) {
|
||||||
BlockPos offset = pos.relative(state.getValue(GantryCarriageBlock.FACING));
|
BlockPos offset = pos.relative(state.getValue(GantryCarriageBlock.FACING));
|
||||||
if (!visited.contains(offset))
|
if (!visited.contains(offset))
|
||||||
frontier.add(offset);
|
frontier.add(offset);
|
||||||
|
@ -495,7 +496,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveGantryShaft(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
protected void moveGantryShaft(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
||||||
BlockState state) {
|
BlockState state) {
|
||||||
for (Direction d : Iterate.directions) {
|
for (Direction d : Iterate.directions) {
|
||||||
BlockPos offset = pos.relative(d);
|
BlockPos offset = pos.relative(d);
|
||||||
if (!visited.contains(offset)) {
|
if (!visited.contains(offset)) {
|
||||||
|
@ -569,7 +570,7 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean moveMechanicalPiston(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
private boolean moveMechanicalPiston(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
|
||||||
BlockState state) throws AssemblyException {
|
BlockState state) throws AssemblyException {
|
||||||
Direction direction = state.getValue(MechanicalPistonBlock.FACING);
|
Direction direction = state.getValue(MechanicalPistonBlock.FACING);
|
||||||
PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE);
|
PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE);
|
||||||
if (pistonState == PistonState.MOVING)
|
if (pistonState == PistonState.MOVING)
|
||||||
|
@ -593,11 +594,10 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean moveChassis(Level world, BlockPos pos, Direction movementDirection, Queue<BlockPos> frontier,
|
private boolean moveChassis(Level world, BlockPos pos, Direction movementDirection, Queue<BlockPos> frontier,
|
||||||
Set<BlockPos> visited) {
|
Set<BlockPos> visited) {
|
||||||
BlockEntity be = world.getBlockEntity(pos);
|
BlockEntity be = world.getBlockEntity(pos);
|
||||||
if (!(be instanceof ChassisBlockEntity))
|
if (!(be instanceof ChassisBlockEntity chassis))
|
||||||
return false;
|
return false;
|
||||||
ChassisBlockEntity chassis = (ChassisBlockEntity) be;
|
|
||||||
chassis.addAttachedChasses(frontier, visited);
|
chassis.addAttachedChasses(frontier, visited);
|
||||||
List<BlockPos> includedBlockPositions = chassis.getIncludedBlockPositions(movementDirection, false);
|
List<BlockPos> includedBlockPositions = chassis.getIncludedBlockPositions(movementDirection, false);
|
||||||
if (includedBlockPositions == null)
|
if (includedBlockPositions == null)
|
||||||
|
@ -650,9 +650,8 @@ public abstract class Contraption {
|
||||||
|
|
||||||
if (be != null) {
|
if (be != null) {
|
||||||
CompoundTag updateTag = be.getUpdateTag();
|
CompoundTag updateTag = be.getUpdateTag();
|
||||||
// the ID needs to be in the tag so the client can properly add the BlockEntity
|
// empty tags are intentionally kept, see writeBlocksCompound
|
||||||
ResourceLocation id = Objects.requireNonNull(BlockEntityType.getKey(be.getType()));
|
// for testing, this line can be commented to emulate legacy behavior
|
||||||
updateTag.putString("id", id.toString());
|
|
||||||
updateTags.put(localPos, updateTag);
|
updateTags.put(localPos, updateTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,8 +668,8 @@ public abstract class Contraption {
|
||||||
|
|
||||||
if (be instanceof CreativeCrateBlockEntity
|
if (be instanceof CreativeCrateBlockEntity
|
||||||
&& ((CreativeCrateBlockEntity) be).getBehaviour(FilteringBehaviour.TYPE)
|
&& ((CreativeCrateBlockEntity) be).getBehaviour(FilteringBehaviour.TYPE)
|
||||||
.getFilter()
|
.getFilter()
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
hasUniversalCreativeCrate = true;
|
hasUniversalCreativeCrate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,9 +679,12 @@ public abstract class Contraption {
|
||||||
|
|
||||||
CompoundTag nbt = structureBlockInfo.nbt();
|
CompoundTag nbt = structureBlockInfo.nbt();
|
||||||
BlockPos controllerPos = nbt.contains("Controller") ?
|
BlockPos controllerPos = nbt.contains("Controller") ?
|
||||||
toLocalPos(NbtUtils.readBlockPos(nbt.getCompound("Controller"))) :
|
toLocalPos(NbtUtils.readBlockPos(nbt.getCompound("Controller"))) :
|
||||||
localPos;
|
localPos;
|
||||||
nbt.put("Controller", NbtUtils.writeBlockPos(controllerPos));
|
nbt.put("Controller", NbtUtils.writeBlockPos(controllerPos));
|
||||||
|
|
||||||
|
if (updateTags.containsKey(localPos))
|
||||||
|
updateTags.get(localPos).put("Controller", NbtUtils.writeBlockPos(controllerPos));
|
||||||
|
|
||||||
if (multiBlockBE.isController() && multiBlockBE.getHeight() <= 1 && multiBlockBE.getWidth() <= 1) {
|
if (multiBlockBE.isController() && multiBlockBE.getHeight() <= 1 && multiBlockBE.getWidth() <= 1) {
|
||||||
nbt.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below(Integer.MAX_VALUE - 1)));
|
nbt.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below(Integer.MAX_VALUE - 1)));
|
||||||
|
@ -731,17 +733,17 @@ public abstract class Contraption {
|
||||||
|
|
||||||
capturedMultiblocks.clear();
|
capturedMultiblocks.clear();
|
||||||
nbt.getList("CapturedMultiblocks", Tag.TAG_COMPOUND).forEach(c -> {
|
nbt.getList("CapturedMultiblocks", Tag.TAG_COMPOUND).forEach(c -> {
|
||||||
CompoundTag tag = (CompoundTag) c;
|
CompoundTag tag = (CompoundTag) c;
|
||||||
if (!tag.contains("Controller", Tag.TAG_COMPOUND) && !tag.contains("Parts", Tag.TAG_LIST))
|
if (!tag.contains("Controller", Tag.TAG_COMPOUND) && !tag.contains("Parts", Tag.TAG_LIST))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockPos controllerPos = NbtUtils.readBlockPos(tag.getCompound("Controller"));
|
BlockPos controllerPos = NbtUtils.readBlockPos(tag.getCompound("Controller"));
|
||||||
tag.getList("Parts", Tag.TAG_COMPOUND).forEach(part -> {
|
tag.getList("Parts", Tag.TAG_COMPOUND).forEach(part -> {
|
||||||
BlockPos partPos = NbtUtils.readBlockPos((CompoundTag) part);
|
BlockPos partPos = NbtUtils.readBlockPos((CompoundTag) part);
|
||||||
StructureBlockInfo partInfo = this.blocks.get(partPos);
|
StructureBlockInfo partInfo = this.blocks.get(partPos);
|
||||||
capturedMultiblocks.put(controllerPos, partInfo);
|
capturedMultiblocks.put(controllerPos, partInfo);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
storage.read(nbt, spawnData, this);
|
storage.read(nbt, spawnData, this);
|
||||||
|
|
||||||
|
@ -902,10 +904,12 @@ public abstract class Contraption {
|
||||||
// for client sync, treat the updateTag as the data
|
// for client sync, treat the updateTag as the data
|
||||||
if (updateTag != null) {
|
if (updateTag != null) {
|
||||||
c.put("Data", updateTag);
|
c.put("Data", updateTag);
|
||||||
}
|
} else if (block.nbt() != null) {
|
||||||
// legacy: use full data if update tag is not available
|
// an updateTag is saved for all BlockEntities, even when empty.
|
||||||
if (updateTag == null && block.nbt() != null) {
|
// this case means that the contraption was assembled pre-updateTags.
|
||||||
|
// in this case, we need to use the full BlockEntity data.
|
||||||
c.put("Data", block.nbt());
|
c.put("Data", block.nbt());
|
||||||
|
NBTHelper.putMarker(c, "Legacy");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// otherwise, write actual data as the data, save updateTag on its own
|
// otherwise, write actual data as the data, save updateTag on its own
|
||||||
|
@ -960,29 +964,17 @@ public abstract class Contraption {
|
||||||
|
|
||||||
if (c.contains("UpdateTag", Tag.TAG_COMPOUND)) {
|
if (c.contains("UpdateTag", Tag.TAG_COMPOUND)) {
|
||||||
CompoundTag updateTag = c.getCompound("UpdateTag");
|
CompoundTag updateTag = c.getCompound("UpdateTag");
|
||||||
if (!updateTag.isEmpty()) {
|
// it's very important that empty tags are read here. see writeBlocksCompound
|
||||||
this.updateTags.put(info.pos(), updateTag);
|
this.updateTags.put(info.pos(), updateTag);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!world.isClientSide)
|
if (!world.isClientSide)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CompoundTag tag = info.nbt();
|
// create the BlockEntity client-side for rendering
|
||||||
if (tag == null)
|
BlockEntity be = readBlockEntity(world, info, c);
|
||||||
return;
|
|
||||||
|
|
||||||
tag.putInt("x", info.pos().getX());
|
|
||||||
tag.putInt("y", info.pos().getY());
|
|
||||||
tag.putInt("z", info.pos().getZ());
|
|
||||||
|
|
||||||
BlockEntity be = BlockEntity.loadStatic(info.pos(), info.state(), tag);
|
|
||||||
if (be == null)
|
if (be == null)
|
||||||
return;
|
return;
|
||||||
be.setLevel(world);
|
|
||||||
if (be instanceof KineticBlockEntity kbe)
|
|
||||||
kbe.setSpeed(0);
|
|
||||||
be.getBlockState();
|
|
||||||
|
|
||||||
presentBlockEntities.put(info.pos(), be);
|
presentBlockEntities.put(info.pos(), be);
|
||||||
modelData.put(info.pos(), be.getModelData());
|
modelData.put(info.pos(), be.getModelData());
|
||||||
|
@ -994,8 +986,49 @@ public abstract class Contraption {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static BlockEntity readBlockEntity(Level level, StructureBlockInfo info, CompoundTag tag) {
|
||||||
|
BlockState state = info.state();
|
||||||
|
BlockPos pos = info.pos();
|
||||||
|
CompoundTag nbt = info.nbt();
|
||||||
|
|
||||||
|
if (tag.contains("Legacy")) {
|
||||||
|
// for contraptions that were assembled pre-updateTags, we need to use the old strategy.
|
||||||
|
if (nbt == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
nbt.putInt("x", pos.getX());
|
||||||
|
nbt.putInt("y", pos.getY());
|
||||||
|
nbt.putInt("z", pos.getZ());
|
||||||
|
|
||||||
|
BlockEntity be = BlockEntity.loadStatic(pos, state, nbt);
|
||||||
|
postprocessReadBlockEntity(level, be);
|
||||||
|
return be;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state.hasBlockEntity() || !(state.getBlock() instanceof EntityBlock entityBlock))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
BlockEntity be = entityBlock.newBlockEntity(pos, state);
|
||||||
|
postprocessReadBlockEntity(level, be);
|
||||||
|
if (be != null && nbt != null) {
|
||||||
|
be.handleUpdateTag(nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return be;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void postprocessReadBlockEntity(Level level, @Nullable BlockEntity be) {
|
||||||
|
if (be != null) {
|
||||||
|
be.setLevel(level);
|
||||||
|
if (be instanceof KineticBlockEntity kbe) {
|
||||||
|
kbe.setSpeed(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static StructureBlockInfo readStructureBlockInfo(CompoundTag blockListEntry,
|
private static StructureBlockInfo readStructureBlockInfo(CompoundTag blockListEntry,
|
||||||
HashMapPalette<BlockState> palette) {
|
HashMapPalette<BlockState> palette) {
|
||||||
return new StructureBlockInfo(BlockPos.of(blockListEntry.getLong("Pos")),
|
return new StructureBlockInfo(BlockPos.of(blockListEntry.getLong("Pos")),
|
||||||
Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))),
|
Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))),
|
||||||
blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null);
|
blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null);
|
||||||
|
@ -1021,7 +1054,7 @@ public abstract class Contraption {
|
||||||
|
|
||||||
for (boolean brittles : Iterate.trueAndFalse) {
|
for (boolean brittles : Iterate.trueAndFalse) {
|
||||||
for (Iterator<StructureBlockInfo> iterator = blocks.values()
|
for (Iterator<StructureBlockInfo> iterator = blocks.values()
|
||||||
.iterator(); iterator.hasNext();) {
|
.iterator(); iterator.hasNext(); ) {
|
||||||
StructureBlockInfo block = iterator.next();
|
StructureBlockInfo block = iterator.next();
|
||||||
if (brittles != BlockMovementChecks.isBrittle(block.state()))
|
if (brittles != BlockMovementChecks.isBrittle(block.state()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1126,7 +1159,7 @@ public abstract class Contraption {
|
||||||
if (blockState.getDestroySpeed(world, targetPos) == -1 || (state.getCollisionShape(world, targetPos)
|
if (blockState.getDestroySpeed(world, targetPos) == -1 || (state.getCollisionShape(world, targetPos)
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
&& !blockState.getCollisionShape(world, targetPos)
|
&& !blockState.getCollisionShape(world, targetPos)
|
||||||
.isEmpty())) {
|
.isEmpty())) {
|
||||||
if (targetPos.getY() == world.getMinBuildHeight())
|
if (targetPos.getY() == world.getMinBuildHeight())
|
||||||
targetPos = targetPos.above();
|
targetPos = targetPos.above();
|
||||||
world.levelEvent(2001, targetPos, Block.getId(state));
|
world.levelEvent(2001, targetPos, Block.getId(state));
|
||||||
|
@ -1147,7 +1180,7 @@ public abstract class Contraption {
|
||||||
state = state.setValue(SlidingDoorBlock.VISIBLE, !state.getValue(SlidingDoorBlock.OPEN))
|
state = state.setValue(SlidingDoorBlock.VISIBLE, !state.getValue(SlidingDoorBlock.OPEN))
|
||||||
.setValue(SlidingDoorBlock.POWERED, false);
|
.setValue(SlidingDoorBlock.POWERED, false);
|
||||||
// Stop Sculk shriekers from getting "stuck" if moved mid-shriek.
|
// Stop Sculk shriekers from getting "stuck" if moved mid-shriek.
|
||||||
if(state.is(Blocks.SCULK_SHRIEKER)){
|
if (state.is(Blocks.SCULK_SHRIEKER)) {
|
||||||
state = Blocks.SCULK_SHRIEKER.defaultBlockState();
|
state = Blocks.SCULK_SHRIEKER.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1199,7 @@ public abstract class Contraption {
|
||||||
CompoundTag tag = block.nbt();
|
CompoundTag tag = block.nbt();
|
||||||
|
|
||||||
// Temporary fix: Calling load(CompoundTag tag) on a Sculk sensor causes it to not react to vibrations.
|
// Temporary fix: Calling load(CompoundTag tag) on a Sculk sensor causes it to not react to vibrations.
|
||||||
if(state.is(Blocks.SCULK_SENSOR) || state.is(Blocks.SCULK_SHRIEKER))
|
if (state.is(Blocks.SCULK_SENSOR) || state.is(Blocks.SCULK_SHRIEKER))
|
||||||
tag = null;
|
tag = null;
|
||||||
|
|
||||||
if (blockEntity != null)
|
if (blockEntity != null)
|
||||||
|
@ -1433,19 +1466,19 @@ public abstract class Contraption {
|
||||||
simplifiedEntityColliderProvider.cancel(false);
|
simplifiedEntityColliderProvider.cancel(false);
|
||||||
}
|
}
|
||||||
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
|
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
|
||||||
VoxelShape combinedShape = Shapes.empty();
|
VoxelShape combinedShape = Shapes.empty();
|
||||||
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
|
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
|
||||||
StructureBlockInfo info = entry.getValue();
|
StructureBlockInfo info = entry.getValue();
|
||||||
BlockPos localPos = entry.getKey();
|
BlockPos localPos = entry.getKey();
|
||||||
VoxelShape collisionShape = info.state().getCollisionShape(world, localPos, CollisionContext.empty());
|
VoxelShape collisionShape = info.state().getCollisionShape(world, localPos, CollisionContext.empty());
|
||||||
if (collisionShape.isEmpty())
|
if (collisionShape.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
combinedShape = Shapes.joinUnoptimized(combinedShape,
|
combinedShape = Shapes.joinUnoptimized(combinedShape,
|
||||||
collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), BooleanOp.OR);
|
collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), BooleanOp.OR);
|
||||||
}
|
}
|
||||||
return combinedShape.optimize()
|
return combinedShape.optimize()
|
||||||
.toAabbs();
|
.toAabbs();
|
||||||
})
|
})
|
||||||
.thenAccept(r -> {
|
.thenAccept(r -> {
|
||||||
simplifiedEntityColliders = Optional.of(r);
|
simplifiedEntityColliders = Optional.of(r);
|
||||||
});
|
});
|
||||||
|
@ -1453,12 +1486,12 @@ public abstract class Contraption {
|
||||||
|
|
||||||
public static float getRadius(Set<BlockPos> blocks, Direction.Axis axis) {
|
public static float getRadius(Set<BlockPos> blocks, Direction.Axis axis) {
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case X:
|
case X:
|
||||||
return getMaxDistSqr(blocks, BlockPos::getY, BlockPos::getZ);
|
return getMaxDistSqr(blocks, BlockPos::getY, BlockPos::getZ);
|
||||||
case Y:
|
case Y:
|
||||||
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getZ);
|
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getZ);
|
||||||
case Z:
|
case Z:
|
||||||
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getY);
|
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getY);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException("Impossible axis");
|
throw new IllegalStateException("Impossible axis");
|
||||||
|
|
|
@ -771,15 +771,12 @@ public class ContraptionCollider {
|
||||||
|
|
||||||
MovementBehaviour movementBehaviour = MovementBehaviour.REGISTRY.get(blockInfo.state());
|
MovementBehaviour movementBehaviour = MovementBehaviour.REGISTRY.get(blockInfo.state());
|
||||||
if (movementBehaviour != null) {
|
if (movementBehaviour != null) {
|
||||||
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
|
if (movementBehaviour instanceof BlockBreakingMovementBehaviour behaviour) {
|
||||||
BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour;
|
|
||||||
if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider)
|
if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider)
|
||||||
return true;
|
return true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (movementBehaviour instanceof HarvesterMovementBehaviour) {
|
if (movementBehaviour instanceof HarvesterMovementBehaviour harvesterMovementBehaviour) {
|
||||||
HarvesterMovementBehaviour harvesterMovementBehaviour =
|
|
||||||
(HarvesterMovementBehaviour) movementBehaviour;
|
|
||||||
if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState)
|
if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState)
|
||||||
&& !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState)
|
&& !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState)
|
||||||
&& !emptyCollider)
|
&& !emptyCollider)
|
||||||
|
|
|
@ -49,9 +49,8 @@ public class ContraptionHandlerClient {
|
||||||
public static void preventRemotePlayersWalkingAnimations(PlayerTickEvent event) {
|
public static void preventRemotePlayersWalkingAnimations(PlayerTickEvent event) {
|
||||||
if (event.phase == Phase.START)
|
if (event.phase == Phase.START)
|
||||||
return;
|
return;
|
||||||
if (!(event.player instanceof RemotePlayer))
|
if (!(event.player instanceof RemotePlayer remotePlayer))
|
||||||
return;
|
return;
|
||||||
RemotePlayer remotePlayer = (RemotePlayer) event.player;
|
|
||||||
CompoundTag data = remotePlayer.getPersistentData();
|
CompoundTag data = remotePlayer.getPersistentData();
|
||||||
if (!data.contains("LastOverrideLimbSwingUpdate"))
|
if (!data.contains("LastOverrideLimbSwingUpdate"))
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +91,7 @@ public class ContraptionHandlerClient {
|
||||||
Collection<WeakReference<AbstractContraptionEntity>> contraptions =
|
Collection<WeakReference<AbstractContraptionEntity>> contraptions =
|
||||||
ContraptionHandler.loadedContraptions.get(mc.level)
|
ContraptionHandler.loadedContraptions.get(mc.level)
|
||||||
.values();
|
.values();
|
||||||
|
|
||||||
double bestDistance = Double.MAX_VALUE;
|
double bestDistance = Double.MAX_VALUE;
|
||||||
BlockHitResult bestResult = null;
|
BlockHitResult bestResult = null;
|
||||||
AbstractContraptionEntity bestEntity = null;
|
AbstractContraptionEntity bestEntity = null;
|
||||||
|
@ -108,23 +107,23 @@ public class ContraptionHandlerClient {
|
||||||
BlockHitResult rayTraceResult = rayTraceContraption(origin, target, contraptionEntity);
|
BlockHitResult rayTraceResult = rayTraceContraption(origin, target, contraptionEntity);
|
||||||
if (rayTraceResult == null)
|
if (rayTraceResult == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double distance = contraptionEntity.toGlobalVector(rayTraceResult.getLocation(), 1).distanceTo(origin);
|
double distance = contraptionEntity.toGlobalVector(rayTraceResult.getLocation(), 1).distanceTo(origin);
|
||||||
if (distance > bestDistance)
|
if (distance > bestDistance)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bestResult = rayTraceResult;
|
bestResult = rayTraceResult;
|
||||||
bestDistance = distance;
|
bestDistance = distance;
|
||||||
bestEntity = contraptionEntity;
|
bestEntity = contraptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestResult == null)
|
if (bestResult == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InteractionHand hand = event.getHand();
|
InteractionHand hand = event.getHand();
|
||||||
Direction face = bestResult.getDirection();
|
Direction face = bestResult.getDirection();
|
||||||
BlockPos pos = bestResult.getBlockPos();
|
BlockPos pos = bestResult.getBlockPos();
|
||||||
|
|
||||||
if (bestEntity.handlePlayerInteraction(player, pos, face, hand)) {
|
if (bestEntity.handlePlayerInteraction(player, pos, face, hand)) {
|
||||||
AllPackets.getChannel()
|
AllPackets.getChannel()
|
||||||
.sendToServer(new ContraptionInteractionPacket(bestEntity, hand, pos, face));
|
.sendToServer(new ContraptionInteractionPacket(bestEntity, hand, pos, face));
|
||||||
|
@ -136,7 +135,7 @@ public class ContraptionHandlerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean handleSpecialInteractions(AbstractContraptionEntity contraptionEntity, Player player,
|
private static boolean handleSpecialInteractions(AbstractContraptionEntity contraptionEntity, Player player,
|
||||||
BlockPos localPos, Direction side, InteractionHand interactionHand) {
|
BlockPos localPos, Direction side, InteractionHand interactionHand) {
|
||||||
if (AllItems.WRENCH.isIn(player.getItemInHand(interactionHand))
|
if (AllItems.WRENCH.isIn(player.getItemInHand(interactionHand))
|
||||||
&& contraptionEntity instanceof CarriageContraptionEntity car)
|
&& contraptionEntity instanceof CarriageContraptionEntity car)
|
||||||
return TrainRelocator.carriageWrenched(car.toGlobalVector(VecHelper.getCenterOf(localPos), 1), car);
|
return TrainRelocator.carriageWrenched(car.toGlobalVector(VecHelper.getCenterOf(localPos), 1), car);
|
||||||
|
@ -157,7 +156,7 @@ public class ContraptionHandlerClient {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static BlockHitResult rayTraceContraption(Vec3 origin, Vec3 target,
|
public static BlockHitResult rayTraceContraption(Vec3 origin, Vec3 target,
|
||||||
AbstractContraptionEntity contraptionEntity) {
|
AbstractContraptionEntity contraptionEntity) {
|
||||||
Vec3 localOrigin = contraptionEntity.toLocalVector(origin, 1);
|
Vec3 localOrigin = contraptionEntity.toLocalVector(origin, 1);
|
||||||
Vec3 localTarget = contraptionEntity.toLocalVector(target, 1);
|
Vec3 localTarget = contraptionEntity.toLocalVector(target, 1);
|
||||||
Contraption contraption = contraptionEntity.getContraption();
|
Contraption contraption = contraptionEntity.getContraption();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ControlledContraptionEntity create(Level world, IControlContraption controller,
|
public static ControlledContraptionEntity create(Level world, IControlContraption controller,
|
||||||
Contraption contraption) {
|
Contraption contraption) {
|
||||||
ControlledContraptionEntity entity =
|
ControlledContraptionEntity entity =
|
||||||
new ControlledContraptionEntity(AllEntityTypes.CONTROLLED_CONTRAPTION.get(), world);
|
new ControlledContraptionEntity(AllEntityTypes.CONTROLLED_CONTRAPTION.get(), world);
|
||||||
entity.controllerPos = controller.getBlockPosition();
|
entity.controllerPos = controller.getBlockPosition();
|
||||||
|
@ -144,11 +144,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {}
|
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {}
|
public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {
|
||||||
|
}
|
||||||
|
|
||||||
protected void tickContraption() {
|
protected void tickContraption() {
|
||||||
angleDelta = angle - prevAngle;
|
angleDelta = angle - prevAngle;
|
||||||
|
@ -173,14 +175,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor,
|
protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor,
|
||||||
Vec3 actorPosition, BlockPos gridPosition) {
|
Vec3 actorPosition, BlockPos gridPosition) {
|
||||||
if (super.shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition))
|
if (super.shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Special activation timer for actors in the center of a bearing contraption
|
// Special activation timer for actors in the center of a bearing contraption
|
||||||
if (!(contraption instanceof BearingContraption))
|
if (!(contraption instanceof BearingContraption bc))
|
||||||
return false;
|
return false;
|
||||||
BearingContraption bc = (BearingContraption) contraption;
|
|
||||||
Direction facing = bc.getFacing();
|
Direction facing = bc.getFacing();
|
||||||
Vec3 activeAreaOffset = actor.getActiveAreaOffset(context);
|
Vec3 activeAreaOffset = actor.getActiveAreaOffset(context);
|
||||||
if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vec3.atLowerCornerOf(facing.getNormal())))
|
if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vec3.atLowerCornerOf(facing.getNormal())))
|
||||||
|
@ -248,10 +249,10 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
if (axis != null) {
|
if (axis != null) {
|
||||||
TransformStack.of(matrixStack)
|
TransformStack.of(matrixStack)
|
||||||
.nudge(getId())
|
.nudge(getId())
|
||||||
.center()
|
.center()
|
||||||
.rotateDegrees(angle, axis)
|
.rotateDegrees(angle, axis)
|
||||||
.uncenter();
|
.uncenter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OrientedContraptionEntity createAtYaw(Level world, Contraption contraption,
|
public static OrientedContraptionEntity createAtYaw(Level world, Contraption contraption,
|
||||||
Direction initialOrientation, float initialYaw) {
|
Direction initialOrientation, float initialYaw) {
|
||||||
OrientedContraptionEntity entity = create(world, contraption, initialOrientation);
|
OrientedContraptionEntity entity = create(world, contraption, initialOrientation);
|
||||||
entity.startAtYaw(initialYaw);
|
entity.startAtYaw(initialYaw);
|
||||||
entity.manuallyPlaced = true;
|
entity.manuallyPlaced = true;
|
||||||
|
@ -258,8 +258,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
boolean rotationLock = false;
|
boolean rotationLock = false;
|
||||||
boolean pauseWhileRotating = false;
|
boolean pauseWhileRotating = false;
|
||||||
boolean wasStalled = isStalled();
|
boolean wasStalled = isStalled();
|
||||||
if (contraption instanceof MountedContraption) {
|
if (contraption instanceof MountedContraption mountedContraption) {
|
||||||
MountedContraption mountedContraption = (MountedContraption) contraption;
|
|
||||||
rotationLock = mountedContraption.rotationMode == CartMovementMode.ROTATION_LOCKED;
|
rotationLock = mountedContraption.rotationMode == CartMovementMode.ROTATION_LOCKED;
|
||||||
pauseWhileRotating = mountedContraption.rotationMode == CartMovementMode.ROTATE_PAUSED;
|
pauseWhileRotating = mountedContraption.rotationMode == CartMovementMode.ROTATE_PAUSED;
|
||||||
}
|
}
|
||||||
|
@ -345,15 +344,13 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contraption instanceof StabilizedContraption) {
|
if (contraption instanceof StabilizedContraption stabilized) {
|
||||||
if (!(riding instanceof OrientedContraptionEntity))
|
if (!(riding instanceof OrientedContraptionEntity parent))
|
||||||
return false;
|
return false;
|
||||||
StabilizedContraption stabilized = (StabilizedContraption) contraption;
|
|
||||||
Direction facing = stabilized.getFacing();
|
Direction facing = stabilized.getFacing();
|
||||||
if (facing.getAxis()
|
if (facing.getAxis()
|
||||||
.isVertical())
|
.isVertical())
|
||||||
return false;
|
return false;
|
||||||
OrientedContraptionEntity parent = (OrientedContraptionEntity) riding;
|
|
||||||
prevYaw = yaw;
|
prevYaw = yaw;
|
||||||
yaw = AngleHelper.wrapAngle180(getInitialYaw() - parent.getInitialYaw()) - parent.getViewYRot(1);
|
yaw = AngleHelper.wrapAngle180(getInitialYaw() - parent.getInitialYaw()) - parent.getViewYRot(1);
|
||||||
return false;
|
return false;
|
||||||
|
@ -372,12 +369,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
Vec3 motion = movementVector.normalize();
|
Vec3 motion = movementVector.normalize();
|
||||||
|
|
||||||
if (!rotationLock) {
|
if (!rotationLock) {
|
||||||
if (riding instanceof AbstractMinecart) {
|
if (riding instanceof AbstractMinecart minecartEntity) {
|
||||||
AbstractMinecart minecartEntity = (AbstractMinecart) riding;
|
|
||||||
BlockPos railPosition = minecartEntity.getCurrentRailPosition();
|
BlockPos railPosition = minecartEntity.getCurrentRailPosition();
|
||||||
BlockState blockState = level().getBlockState(railPosition);
|
BlockState blockState = level().getBlockState(railPosition);
|
||||||
if (blockState.getBlock() instanceof BaseRailBlock) {
|
if (blockState.getBlock() instanceof BaseRailBlock abstractRailBlock) {
|
||||||
BaseRailBlock abstractRailBlock = (BaseRailBlock) blockState.getBlock();
|
|
||||||
RailShape railDirection =
|
RailShape railDirection =
|
||||||
abstractRailBlock.getRailDirection(blockState, level(), railPosition, minecartEntity);
|
abstractRailBlock.getRailDirection(blockState, level(), railPosition, minecartEntity);
|
||||||
motion = VecHelper.project(motion, MinecartSim2020.getRailVec(railDirection));
|
motion = VecHelper.project(motion, MinecartSim2020.getRailVec(railDirection));
|
||||||
|
@ -407,9 +402,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void powerFurnaceCartWithFuelFromStorage(Entity riding) {
|
protected void powerFurnaceCartWithFuelFromStorage(Entity riding) {
|
||||||
if (!(riding instanceof MinecartFurnace))
|
if (!(riding instanceof MinecartFurnace furnaceCart))
|
||||||
return;
|
return;
|
||||||
MinecartFurnace furnaceCart = (MinecartFurnace) riding;
|
|
||||||
|
|
||||||
// Notify to not trigger serialization side-effects
|
// Notify to not trigger serialization side-effects
|
||||||
isSerializingFurnaceCart = true;
|
isSerializingFurnaceCart = true;
|
||||||
|
|
|
@ -44,13 +44,13 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
|
||||||
public boolean isActive(MovementContext context) {
|
public boolean isActive(MovementContext context) {
|
||||||
return MovementBehaviour.super.isActive(context)
|
return MovementBehaviour.super.isActive(context)
|
||||||
&& !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(HarvesterBlock.FACING)
|
&& !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(HarvesterBlock.FACING)
|
||||||
.getOpposite());
|
.getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3 getActiveAreaOffset(MovementContext context) {
|
public Vec3 getActiveAreaOffset(MovementContext context) {
|
||||||
return Vec3.atLowerCornerOf(context.state.getValue(HarvesterBlock.FACING)
|
return Vec3.atLowerCornerOf(context.state.getValue(HarvesterBlock.FACING)
|
||||||
.getNormal())
|
.getNormal())
|
||||||
.scale(.45);
|
.scale(.45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,7 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
|
||||||
boolean harvestPartial = AllConfigs.server().kinetics.harvestPartiallyGrown.get();
|
boolean harvestPartial = AllConfigs.server().kinetics.harvestPartiallyGrown.get();
|
||||||
boolean replant = AllConfigs.server().kinetics.harvesterReplants.get();
|
boolean replant = AllConfigs.server().kinetics.harvesterReplants.get();
|
||||||
|
|
||||||
if (state.getBlock() instanceof CropBlock) {
|
if (state.getBlock() instanceof CropBlock crop) {
|
||||||
CropBlock crop = (CropBlock) state.getBlock();
|
|
||||||
if (harvestPartial)
|
if (harvestPartial)
|
||||||
return state != crop.getStateForAge(0) || !replant;
|
return state != crop.getStateForAge(0) || !replant;
|
||||||
return crop.isMaxAge(state);
|
return crop.isMaxAge(state);
|
||||||
|
@ -107,9 +106,8 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
|
||||||
if (state.getCollisionShape(world, pos)
|
if (state.getCollisionShape(world, pos)
|
||||||
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||||
for (Property<?> property : state.getProperties()) {
|
for (Property<?> property : state.getProperties()) {
|
||||||
if (!(property instanceof IntegerProperty))
|
if (!(property instanceof IntegerProperty ageProperty))
|
||||||
continue;
|
continue;
|
||||||
IntegerProperty ageProperty = (IntegerProperty) property;
|
|
||||||
if (!property.getName()
|
if (!property.getName()
|
||||||
.equals(BlockStateProperties.AGE_1.getName()))
|
.equals(BlockStateProperties.AGE_1.getName()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -168,8 +166,7 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof CropBlock) {
|
if (block instanceof CropBlock crop) {
|
||||||
CropBlock crop = (CropBlock) block;
|
|
||||||
return crop.getStateForAge(0);
|
return crop.getStateForAge(0);
|
||||||
}
|
}
|
||||||
if (block == Blocks.SWEET_BERRY_BUSH) {
|
if (block == Blocks.SWEET_BERRY_BUSH) {
|
||||||
|
@ -208,15 +205,15 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
||||||
if (!VisualizationManager.supportsVisualization(context.world))
|
if (!VisualizationManager.supportsVisualization(context.world))
|
||||||
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld,
|
public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld,
|
||||||
MovementContext movementContext) {
|
MovementContext movementContext) {
|
||||||
return new HarvesterActorVisual(visualizationContext, simulationWorld, movementContext);
|
return new HarvesterActorVisual(visualizationContext, simulationWorld, movementContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
public boolean isActive(MovementContext context) {
|
public boolean isActive(MovementContext context) {
|
||||||
return super.isActive(context)
|
return super.isActive(context)
|
||||||
&& !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(PloughBlock.FACING)
|
&& !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(PloughBlock.FACING)
|
||||||
.getOpposite());
|
.getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,7 +86,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
@Override
|
@Override
|
||||||
public Vec3 getActiveAreaOffset(MovementContext context) {
|
public Vec3 getActiveAreaOffset(MovementContext context) {
|
||||||
return Vec3.atLowerCornerOf(context.state.getValue(PloughBlock.FACING)
|
return Vec3.atLowerCornerOf(context.state.getValue(PloughBlock.FACING)
|
||||||
.getNormal())
|
.getNormal())
|
||||||
.scale(.45);
|
.scale(.45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,12 +120,11 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
protected void onBlockBroken(MovementContext context, BlockPos pos, BlockState brokenState) {
|
protected void onBlockBroken(MovementContext context, BlockPos pos, BlockState brokenState) {
|
||||||
super.onBlockBroken(context, pos, brokenState);
|
super.onBlockBroken(context, pos, brokenState);
|
||||||
|
|
||||||
if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerLevel) {
|
if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerLevel world) {
|
||||||
ServerLevel world = (ServerLevel) context.world;
|
|
||||||
brokenState.getDrops(new LootParams.Builder(world).withParameter(LootContextParams.BLOCK_STATE, brokenState)
|
brokenState.getDrops(new LootParams.Builder(world).withParameter(LootContextParams.BLOCK_STATE, brokenState)
|
||||||
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
|
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
|
||||||
.withParameter(LootContextParams.THIS_ENTITY, getPlayer(context))
|
.withParameter(LootContextParams.THIS_ENTITY, getPlayer(context))
|
||||||
.withParameter(LootContextParams.TOOL, new ItemStack(Items.IRON_SHOVEL)))
|
.withParameter(LootContextParams.TOOL, new ItemStack(Items.IRON_SHOVEL)))
|
||||||
.forEach(s -> dropItem(context, s));
|
.forEach(s -> dropItem(context, s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class RollerBlockEntity extends SmartBlockEntity {
|
||||||
@Override
|
@Override
|
||||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||||
behaviours.add(filtering = new FilteringBehaviour(this, new RollerValueBox(3)));
|
behaviours.add(filtering = new FilteringBehaviour(this, new RollerValueBox(3)));
|
||||||
behaviours.add(mode = new ScrollOptionBehaviour<RollingMode>(RollingMode.class,
|
behaviours.add(mode = new ScrollOptionBehaviour<>(RollingMode.class,
|
||||||
CreateLang.translateDirect("contraptions.roller_mode"), this, new RollerValueBox(-3)));
|
CreateLang.translateDirect("contraptions.roller_mode"), this, new RollerValueBox(-3)));
|
||||||
|
|
||||||
filtering.setLabel(CreateLang.translateDirect("contraptions.mechanical_roller.pave_material"));
|
filtering.setLabel(CreateLang.translateDirect("contraptions.mechanical_roller.pave_material"));
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ControlsHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startControlling(AbstractContraptionEntity entity, BlockPos controllerLocalPos) {
|
public static void startControlling(AbstractContraptionEntity entity, BlockPos controllerLocalPos) {
|
||||||
entityRef = new WeakReference<AbstractContraptionEntity>(entity);
|
entityRef = new WeakReference<>(entity);
|
||||||
controlsPos = controllerLocalPos;
|
controlsPos = controllerLocalPos;
|
||||||
|
|
||||||
Minecraft.getInstance().player.displayClientMessage(
|
Minecraft.getInstance().player.displayClientMessage(
|
||||||
|
@ -108,9 +108,9 @@ public class ControlsHandler {
|
||||||
// Keepalive Pressed Keys
|
// Keepalive Pressed Keys
|
||||||
if (packetCooldown == 0) {
|
if (packetCooldown == 0) {
|
||||||
// if (!pressedKeys.isEmpty()) {
|
// if (!pressedKeys.isEmpty()) {
|
||||||
AllPackets.getChannel()
|
AllPackets.getChannel()
|
||||||
.sendToServer(new ControlsInputPacket(pressedKeys, true, entity.getId(), controlsPos, false));
|
.sendToServer(new ControlsInputPacket(pressedKeys, true, entity.getId(), controlsPos, false));
|
||||||
packetCooldown = PACKET_RATE;
|
packetCooldown = PACKET_RATE;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class ControlsServerHandler {
|
||||||
public static void tick(LevelAccessor world) {
|
public static void tick(LevelAccessor world) {
|
||||||
Map<UUID, ControlsContext> map = receivedInputs.get(world);
|
Map<UUID, ControlsContext> map = receivedInputs.get(world);
|
||||||
for (Iterator<Entry<UUID, ControlsContext>> iterator = map.entrySet()
|
for (Iterator<Entry<UUID, ControlsContext>> iterator = map.entrySet()
|
||||||
.iterator(); iterator.hasNext();) {
|
.iterator(); iterator.hasNext(); ) {
|
||||||
|
|
||||||
Entry<UUID, ControlsContext> entry = iterator.next();
|
Entry<UUID, ControlsContext> entry = iterator.next();
|
||||||
ControlsContext ctx = entry.getValue();
|
ControlsContext ctx = entry.getValue();
|
||||||
|
@ -35,7 +35,7 @@ public class ControlsServerHandler {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<ManuallyPressedKey> entryIterator = list.iterator(); entryIterator.hasNext();) {
|
for (Iterator<ManuallyPressedKey> entryIterator = list.iterator(); entryIterator.hasNext(); ) {
|
||||||
ManuallyPressedKey pressedKey = entryIterator.next();
|
ManuallyPressedKey pressedKey = entryIterator.next();
|
||||||
pressedKey.decrement();
|
pressedKey.decrement();
|
||||||
if (!pressedKey.isAlive())
|
if (!pressedKey.isAlive())
|
||||||
|
@ -61,7 +61,7 @@ public class ControlsServerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void receivePressed(LevelAccessor world, AbstractContraptionEntity entity, BlockPos controlsPos,
|
public static void receivePressed(LevelAccessor world, AbstractContraptionEntity entity, BlockPos controlsPos,
|
||||||
UUID uniqueID, Collection<Integer> collect, boolean pressed) {
|
UUID uniqueID, Collection<Integer> collect, boolean pressed) {
|
||||||
Map<UUID, ControlsContext> map = receivedInputs.get(world);
|
Map<UUID, ControlsContext> map = receivedInputs.get(world);
|
||||||
|
|
||||||
if (map.containsKey(uniqueID) && map.get(uniqueID).entity != entity)
|
if (map.containsKey(uniqueID) && map.get(uniqueID).entity != entity)
|
||||||
|
@ -70,9 +70,9 @@ public class ControlsServerHandler {
|
||||||
ControlsContext ctx = map.computeIfAbsent(uniqueID, $ -> new ControlsContext(entity, controlsPos));
|
ControlsContext ctx = map.computeIfAbsent(uniqueID, $ -> new ControlsContext(entity, controlsPos));
|
||||||
Collection<ManuallyPressedKey> list = ctx.keys;
|
Collection<ManuallyPressedKey> list = ctx.keys;
|
||||||
|
|
||||||
WithNext: for (Integer activated : collect) {
|
WithNext:
|
||||||
for (Iterator<ManuallyPressedKey> iterator = list.iterator(); iterator.hasNext();) {
|
for (Integer activated : collect) {
|
||||||
ManuallyPressedKey entry = iterator.next();
|
for (ManuallyPressedKey entry : list) {
|
||||||
Integer inputType = entry.getSecond();
|
Integer inputType = entry.getSecond();
|
||||||
if (inputType.equals(activated)) {
|
if (inputType.equals(activated)) {
|
||||||
if (!pressed)
|
if (!pressed)
|
||||||
|
|
|
@ -291,10 +291,9 @@ public class ClockworkBearingBlockEntity extends KineticBlockEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attach(ControlledContraptionEntity contraption) {
|
public void attach(ControlledContraptionEntity contraption) {
|
||||||
if (!(contraption.getContraption() instanceof ClockworkContraption))
|
if (!(contraption.getContraption() instanceof ClockworkContraption cc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
|
|
||||||
setChanged();
|
setChanged();
|
||||||
Direction facing = getBlockState().getValue(BlockStateProperties.FACING);
|
Direction facing = getBlockState().getValue(BlockStateProperties.FACING);
|
||||||
BlockPos anchor = worldPosition.relative(facing, cc.offset + 1);
|
BlockPos anchor = worldPosition.relative(facing, cc.offset + 1);
|
||||||
|
@ -380,9 +379,8 @@ public class ClockworkBearingBlockEntity extends KineticBlockEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAttachedTo(AbstractContraptionEntity contraption) {
|
public boolean isAttachedTo(AbstractContraptionEntity contraption) {
|
||||||
if (!(contraption.getContraption() instanceof ClockworkContraption))
|
if (!(contraption.getContraption() instanceof ClockworkContraption cc))
|
||||||
return false;
|
return false;
|
||||||
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
|
|
||||||
if (cc.handType == HandType.HOUR)
|
if (cc.handType == HandType.HOUR)
|
||||||
return this.hourHand == contraption;
|
return this.hourHand == contraption;
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,14 +37,16 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
|
||||||
public ItemStack canBeDisabledVia(MovementContext context) {
|
public ItemStack canBeDisabledVia(MovementContext context) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
|
@Override
|
||||||
public boolean disableBlockEntityRendering() {
|
public boolean disableBlockEntityRendering() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
||||||
if (VisualizationManager.supportsVisualization(context.world))
|
if (VisualizationManager.supportsVisualization(context.world))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld,
|
public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld,
|
||||||
MovementContext movementContext) {
|
MovementContext movementContext) {
|
||||||
return new StabilizedBearingVisual(visualizationContext, simulationWorld, movementContext);
|
return new StabilizedBearingVisual(visualizationContext, simulationWorld, movementContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,13 +93,11 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
|
||||||
Direction.Axis axis = facing.getAxis();
|
Direction.Axis axis = facing.getAxis();
|
||||||
AbstractContraptionEntity entity = context.contraption.entity;
|
AbstractContraptionEntity entity = context.contraption.entity;
|
||||||
|
|
||||||
if (entity instanceof ControlledContraptionEntity) {
|
if (entity instanceof ControlledContraptionEntity controlledCE) {
|
||||||
ControlledContraptionEntity controlledCE = (ControlledContraptionEntity) entity;
|
|
||||||
if (context.contraption.canBeStabilized(facing, context.localPos))
|
if (context.contraption.canBeStabilized(facing, context.localPos))
|
||||||
offset = -controlledCE.getAngle(renderPartialTicks);
|
offset = -controlledCE.getAngle(renderPartialTicks);
|
||||||
|
|
||||||
} else if (entity instanceof OrientedContraptionEntity) {
|
} else if (entity instanceof OrientedContraptionEntity orientedCE) {
|
||||||
OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity;
|
|
||||||
if (axis.isVertical())
|
if (axis.isVertical())
|
||||||
offset = -orientedCE.getViewYRot(renderPartialTicks);
|
offset = -orientedCE.getViewYRot(renderPartialTicks);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -108,8 +108,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
|
||||||
continue;
|
continue;
|
||||||
visited.add(current);
|
visited.add(current);
|
||||||
BlockEntity blockEntity = level.getBlockEntity(current);
|
BlockEntity blockEntity = level.getBlockEntity(current);
|
||||||
if (blockEntity instanceof ChassisBlockEntity) {
|
if (blockEntity instanceof ChassisBlockEntity chassis) {
|
||||||
ChassisBlockEntity chassis = (ChassisBlockEntity) blockEntity;
|
|
||||||
collected.add(chassis);
|
collected.add(chassis);
|
||||||
visited.add(current);
|
visited.add(current);
|
||||||
chassis.addAttachedChasses(frontier, visited);
|
chassis.addAttachedChasses(frontier, visited);
|
||||||
|
@ -126,7 +125,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
|
||||||
if (isRadial()) {
|
if (isRadial()) {
|
||||||
|
|
||||||
// Collect chain of radial chassis
|
// Collect chain of radial chassis
|
||||||
for (int offset : new int[] { -1, 1 }) {
|
for (int offset : new int[]{-1, 1}) {
|
||||||
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
|
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
|
||||||
BlockPos currentPos = worldPosition.relative(direction, offset);
|
BlockPos currentPos = worldPosition.relative(direction, offset);
|
||||||
if (!level.isLoaded(currentPos))
|
if (!level.isLoaded(currentPos))
|
||||||
|
@ -174,7 +173,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
|
||||||
Direction facing = Direction.get(AxisDirection.POSITIVE, axis);
|
Direction facing = Direction.get(AxisDirection.POSITIVE, axis);
|
||||||
int chassisRange = visualize ? currentlySelectedRange : getRange();
|
int chassisRange = visualize ? currentlySelectedRange : getRange();
|
||||||
|
|
||||||
for (int offset : new int[] { 1, -1 }) {
|
for (int offset : new int[]{1, -1}) {
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
facing = facing.getOpposite();
|
facing = facing.getOpposite();
|
||||||
boolean sticky = state.getValue(block.getGlueableSide(state, facing));
|
boolean sticky = state.getValue(block.getGlueableSide(state, facing));
|
||||||
|
@ -255,7 +254,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
|
||||||
class ChassisScrollValueBehaviour extends BulkScrollValueBehaviour {
|
class ChassisScrollValueBehaviour extends BulkScrollValueBehaviour {
|
||||||
|
|
||||||
public ChassisScrollValueBehaviour(Component label, SmartBlockEntity be, ValueBoxTransform slot,
|
public ChassisScrollValueBehaviour(Component label, SmartBlockEntity be, ValueBoxTransform slot,
|
||||||
Function<SmartBlockEntity, List<? extends SmartBlockEntity>> groupGetter) {
|
Function<SmartBlockEntity, List<? extends SmartBlockEntity>> groupGetter) {
|
||||||
super(label, be, slot, groupGetter);
|
super(label, be, slot, groupGetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class ChassisRangeDisplay {
|
||||||
boolean hasWrench = AllItems.WRENCH.isIn(player.getMainHandItem());
|
boolean hasWrench = AllItems.WRENCH.isIn(player.getMainHandItem());
|
||||||
|
|
||||||
for (Iterator<BlockPos> iterator = entries.keySet()
|
for (Iterator<BlockPos> iterator = entries.keySet()
|
||||||
.iterator(); iterator.hasNext();) {
|
.iterator(); iterator.hasNext(); ) {
|
||||||
BlockPos pos = iterator.next();
|
BlockPos pos = iterator.next();
|
||||||
Entry entry = entries.get(pos);
|
Entry entry = entries.get(pos);
|
||||||
if (tickEntry(entry, hasWrench))
|
if (tickEntry(entry, hasWrench))
|
||||||
|
@ -100,7 +100,7 @@ public class ChassisRangeDisplay {
|
||||||
Outliner.getInstance().keep(entry.getOutlineKey());
|
Outliner.getInstance().keep(entry.getOutlineKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<GroupEntry> iterator = groupEntries.iterator(); iterator.hasNext();) {
|
for (Iterator<GroupEntry> iterator = groupEntries.iterator(); iterator.hasNext(); ) {
|
||||||
GroupEntry group = iterator.next();
|
GroupEntry group = iterator.next();
|
||||||
if (tickEntry(group, hasWrench)) {
|
if (tickEntry(group, hasWrench)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
@ -114,18 +114,16 @@ public class ChassisRangeDisplay {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HitResult over = Minecraft.getInstance().hitResult;
|
HitResult over = Minecraft.getInstance().hitResult;
|
||||||
if (!(over instanceof BlockHitResult))
|
if (!(over instanceof BlockHitResult ray))
|
||||||
return;
|
return;
|
||||||
BlockHitResult ray = (BlockHitResult) over;
|
|
||||||
BlockPos pos = ray.getBlockPos();
|
BlockPos pos = ray.getBlockPos();
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (blockEntity == null || blockEntity.isRemoved())
|
if (blockEntity == null || blockEntity.isRemoved())
|
||||||
return;
|
return;
|
||||||
if (!(blockEntity instanceof ChassisBlockEntity))
|
if (!(blockEntity instanceof ChassisBlockEntity chassisBlockEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean ctrl = AllKeys.ctrlDown();
|
boolean ctrl = AllKeys.ctrlDown();
|
||||||
ChassisBlockEntity chassisBlockEntity = (ChassisBlockEntity) blockEntity;
|
|
||||||
|
|
||||||
if (ctrl) {
|
if (ctrl) {
|
||||||
GroupEntry existingGroupForPos = getExistingGroupForPos(pos);
|
GroupEntry existingGroupForPos = getExistingGroupForPos(pos);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.gantry;
|
||||||
import com.simibubi.create.AllBlockEntityTypes;
|
import com.simibubi.create.AllBlockEntityTypes;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.kinetics.base.DirectionalAxisKineticBlock;
|
import com.simibubi.create.content.kinetics.base.DirectionalAxisKineticBlock;
|
||||||
import com.simibubi.create.content.kinetics.base.IRotate;
|
|
||||||
import com.simibubi.create.content.kinetics.gantry.GantryShaftBlock;
|
import com.simibubi.create.content.kinetics.gantry.GantryShaftBlock;
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||||
BlockHitResult hit) {
|
BlockHitResult hit) {
|
||||||
if (!player.mayBuild() || player.isShiftKeyDown())
|
if (!player.mayBuild() || player.isShiftKeyDown())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
if (player.getItemInHand(handIn)
|
if (player.getItemInHand(handIn)
|
||||||
|
@ -77,7 +76,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos updatePos,
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos updatePos,
|
||||||
boolean p_220069_6_) {
|
boolean p_220069_6_) {
|
||||||
if (updatePos.equals(pos.relative(state.getValue(FACING)
|
if (updatePos.equals(pos.relative(state.getValue(FACING)
|
||||||
.getOpposite())) && !canSurvive(state, world, pos))
|
.getOpposite())) && !canSurvive(state, world, pos))
|
||||||
world.destroyBlock(pos, true);
|
world.destroyBlock(pos, true);
|
||||||
|
@ -85,7 +84,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction direction, BlockState otherState, LevelAccessor world,
|
public BlockState updateShape(BlockState state, Direction direction, BlockState otherState, LevelAccessor world,
|
||||||
BlockPos pos, BlockPos p_196271_6_) {
|
BlockPos pos, BlockPos p_196271_6_) {
|
||||||
if (state.getValue(FACING) != direction.getOpposite())
|
if (state.getValue(FACING) != direction.getOpposite())
|
||||||
return state;
|
return state;
|
||||||
return cycleAxisIfNecessary(state, direction, otherState);
|
return cycleAxisIfNecessary(state, direction, otherState);
|
||||||
|
@ -108,9 +107,8 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Axis getValidGantryShaftAxis(BlockState state) {
|
public static Axis getValidGantryShaftAxis(BlockState state) {
|
||||||
if (!(state.getBlock() instanceof GantryCarriageBlock))
|
if (!(state.getBlock() instanceof GantryCarriageBlock block))
|
||||||
return Axis.Y;
|
return Axis.Y;
|
||||||
IRotate block = (IRotate) state.getBlock();
|
|
||||||
Axis rotationAxis = block.getRotationAxis(state);
|
Axis rotationAxis = block.getRotationAxis(state);
|
||||||
Axis facingAxis = state.getValue(FACING)
|
Axis facingAxis = state.getValue(FACING)
|
||||||
.getAxis();
|
.getAxis();
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||||
BlockPos gantryShaftPos = BlockPos.containing(currentPosition).relative(facing.getOpposite());
|
BlockPos gantryShaftPos = BlockPos.containing(currentPosition).relative(facing.getOpposite());
|
||||||
|
|
||||||
BlockEntity be = level().getBlockEntity(gantryShaftPos);
|
BlockEntity be = level().getBlockEntity(gantryShaftPos);
|
||||||
if (!(be instanceof GantryShaftBlockEntity) || !AllBlocks.GANTRY_SHAFT.has(be.getBlockState())) {
|
if (!(be instanceof GantryShaftBlockEntity gantryShaftBlockEntity) || !AllBlocks.GANTRY_SHAFT.has(be.getBlockState())) {
|
||||||
if (!level().isClientSide) {
|
if (!level().isClientSide) {
|
||||||
setContraptionMotion(Vec3.ZERO);
|
setContraptionMotion(Vec3.ZERO);
|
||||||
disassemble();
|
disassemble();
|
||||||
|
@ -112,7 +112,6 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
BlockState blockState = be.getBlockState();
|
BlockState blockState = be.getBlockState();
|
||||||
Direction direction = blockState.getValue(GantryShaftBlock.FACING);
|
Direction direction = blockState.getValue(GantryShaftBlock.FACING);
|
||||||
GantryShaftBlockEntity gantryShaftBlockEntity = (GantryShaftBlockEntity) be;
|
|
||||||
|
|
||||||
float pinionMovementSpeed = gantryShaftBlockEntity.getPinionMovementSpeed();
|
float pinionMovementSpeed = gantryShaftBlockEntity.getPinionMovementSpeed();
|
||||||
if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) {
|
if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) {
|
||||||
|
@ -185,11 +184,13 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {}
|
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {}
|
public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleStallInformation(double x, double y, double z, float angle) {
|
protected void handleStallInformation(double x, double y, double z, float angle) {
|
||||||
|
@ -204,7 +205,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void applyLocalTransforms(PoseStack matrixStack, float partialTicks) {}
|
public void applyLocalTransforms(PoseStack matrixStack, float partialTicks) {
|
||||||
|
}
|
||||||
|
|
||||||
public void updateClientMotion() {
|
public void updateClientMotion() {
|
||||||
float modifier = movementAxis.getAxisDirection()
|
float modifier = movementAxis.getAxisDirection()
|
||||||
|
@ -231,9 +233,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void handlePacket(GantryContraptionUpdatePacket packet) {
|
public static void handlePacket(GantryContraptionUpdatePacket packet) {
|
||||||
Entity entity = Minecraft.getInstance().level.getEntity(packet.entityID);
|
Entity entity = Minecraft.getInstance().level.getEntity(packet.entityID);
|
||||||
if (!(entity instanceof GantryContraptionEntity))
|
if (!(entity instanceof GantryContraptionEntity ce))
|
||||||
return;
|
return;
|
||||||
GantryContraptionEntity ce = (GantryContraptionEntity) entity;
|
|
||||||
ce.axisMotion = packet.motion;
|
ce.axisMotion = packet.motion;
|
||||||
ce.clientOffsetDiff = packet.coord - ce.getAxisCoord();
|
ce.clientOffsetDiff = packet.coord - ce.getAxisCoord();
|
||||||
ce.sequencedOffsetLimit = packet.sequenceLimit;
|
ce.sequencedOffsetLimit = packet.sequenceLimit;
|
||||||
|
|
|
@ -72,9 +72,9 @@ public class CouplingHandler {
|
||||||
Entity entity1 = world.getEntity(cartId1);
|
Entity entity1 = world.getEntity(cartId1);
|
||||||
Entity entity2 = world.getEntity(cartId2);
|
Entity entity2 = world.getEntity(cartId2);
|
||||||
|
|
||||||
if (!(entity1 instanceof AbstractMinecart))
|
if (!(entity1 instanceof AbstractMinecart cart1))
|
||||||
return false;
|
return false;
|
||||||
if (!(entity2 instanceof AbstractMinecart))
|
if (!(entity2 instanceof AbstractMinecart cart2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
String tooMany = "two_couplings_max";
|
String tooMany = "two_couplings_max";
|
||||||
|
@ -97,8 +97,6 @@ public class CouplingHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractMinecart cart1 = (AbstractMinecart) entity1;
|
|
||||||
AbstractMinecart cart2 = (AbstractMinecart) entity2;
|
|
||||||
UUID mainID = cart1.getUUID();
|
UUID mainID = cart1.getUUID();
|
||||||
UUID connectedID = cart2.getUUID();
|
UUID connectedID = cart2.getUUID();
|
||||||
MinecartController mainController = CapabilityMinecartController.getIfPresent(world, mainID);
|
MinecartController mainController = CapabilityMinecartController.getIfPresent(world, mainID);
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class CouplingPhysics {
|
||||||
Couple<Vec3> corrections = Couple.create(null, null);
|
Couple<Vec3> corrections = Couple.create(null, null);
|
||||||
Couple<Float> maxSpeed = carts.map(AbstractMinecart::getMaxCartSpeedOnRail);
|
Couple<Float> maxSpeed = carts.map(AbstractMinecart::getMaxCartSpeedOnRail);
|
||||||
boolean firstLoop = true;
|
boolean firstLoop = true;
|
||||||
for (boolean current : new boolean[] { true, false, true }) {
|
for (boolean current : new boolean[]{true, false, true}) {
|
||||||
AbstractMinecart cart = carts.get(current);
|
AbstractMinecart cart = carts.get(current);
|
||||||
AbstractMinecart otherCart = carts.get(!current);
|
AbstractMinecart otherCart = carts.get(!current);
|
||||||
|
|
||||||
|
@ -54,8 +54,7 @@ public class CouplingPhysics {
|
||||||
BlockPos railPosition = cart.getCurrentRailPosition();
|
BlockPos railPosition = cart.getCurrentRailPosition();
|
||||||
BlockState railState = world.getBlockState(railPosition.above());
|
BlockState railState = world.getBlockState(railPosition.above());
|
||||||
|
|
||||||
if (railState.getBlock() instanceof BaseRailBlock) {
|
if (railState.getBlock() instanceof BaseRailBlock block) {
|
||||||
BaseRailBlock block = (BaseRailBlock) railState.getBlock();
|
|
||||||
shape = block.getRailDirection(railState, world, railPosition, cart);
|
shape = block.getRailDirection(railState, world, railPosition, cart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ public class CouplingPhysics {
|
||||||
correction = shape != null
|
correction = shape != null
|
||||||
? followLinkOnRail(link, pos, correctionMagnitude, MinecartSim2020.getRailVec(shape)).subtract(pos)
|
? followLinkOnRail(link, pos, correctionMagnitude, MinecartSim2020.getRailVec(shape)).subtract(pos)
|
||||||
: link.normalize()
|
: link.normalize()
|
||||||
.scale(correctionMagnitude);
|
.scale(correctionMagnitude);
|
||||||
|
|
||||||
float maxResolveSpeed = 1.75f;
|
float maxResolveSpeed = 1.75f;
|
||||||
correction = VecHelper.clamp(correction, Math.min(maxResolveSpeed, maxSpeed.get(current)));
|
correction = VecHelper.clamp(correction, Math.min(maxResolveSpeed, maxSpeed.get(current)));
|
||||||
|
@ -102,15 +101,14 @@ public class CouplingPhysics {
|
||||||
Couple<RailShape> shapes = carts.mapWithContext((minecart, current) -> {
|
Couple<RailShape> shapes = carts.mapWithContext((minecart, current) -> {
|
||||||
Vec3 vec = nextPositions.get(current);
|
Vec3 vec = nextPositions.get(current);
|
||||||
int x = Mth.floor(vec.x());
|
int x = Mth.floor(vec.x());
|
||||||
int y = Mth.floor(vec.y());
|
int y = Mth.floor(vec.y());
|
||||||
int z = Mth.floor(vec.z());
|
int z = Mth.floor(vec.z());
|
||||||
BlockPos pos = new BlockPos(x, y - 1, z);
|
BlockPos pos = new BlockPos(x, y - 1, z);
|
||||||
if (minecart.level().getBlockState(pos).is(BlockTags.RAILS)) pos = pos.below();
|
if (minecart.level().getBlockState(pos).is(BlockTags.RAILS)) pos = pos.below();
|
||||||
BlockPos railPosition = pos;
|
BlockPos railPosition = pos;
|
||||||
BlockState railState = world.getBlockState(railPosition.above());
|
BlockState railState = world.getBlockState(railPosition.above());
|
||||||
if (!(railState.getBlock() instanceof BaseRailBlock))
|
if (!(railState.getBlock() instanceof BaseRailBlock block))
|
||||||
return null;
|
return null;
|
||||||
BaseRailBlock block = (BaseRailBlock) railState.getBlock();
|
|
||||||
return block.getRailDirection(railState, world, railPosition, minecart);
|
return block.getRailDirection(railState, world, railPosition, minecart);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,8 @@ public class MinecartCouplingItem extends Item {
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public static void handleInteractionWithMinecart(PlayerInteractEvent.EntityInteract event) {
|
public static void handleInteractionWithMinecart(PlayerInteractEvent.EntityInteract event) {
|
||||||
Entity interacted = event.getTarget();
|
Entity interacted = event.getTarget();
|
||||||
if (!(interacted instanceof AbstractMinecart))
|
if (!(interacted instanceof AbstractMinecart minecart))
|
||||||
return;
|
return;
|
||||||
AbstractMinecart minecart = (AbstractMinecart) interacted;
|
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
@ -60,7 +59,7 @@ public class MinecartCouplingItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean onCouplingInteractOnMinecart(PlayerInteractEvent.EntityInteract event,
|
protected static boolean onCouplingInteractOnMinecart(PlayerInteractEvent.EntityInteract event,
|
||||||
AbstractMinecart minecart, Player player, MinecartController controller) {
|
AbstractMinecart minecart, Player player, MinecartController controller) {
|
||||||
Level world = event.getLevel();
|
Level world = event.getLevel();
|
||||||
if (controller.isFullyCoupled()) {
|
if (controller.isFullyCoupled()) {
|
||||||
if (!world.isClientSide)
|
if (!world.isClientSide)
|
||||||
|
@ -73,7 +72,7 @@ public class MinecartCouplingItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecart minecart, Player player,
|
private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecart minecart, Player player,
|
||||||
MinecartController controller) {
|
MinecartController controller) {
|
||||||
int couplings = (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0);
|
int couplings = (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0);
|
||||||
if (couplings == 0)
|
if (couplings == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -105,15 +105,15 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
|
||||||
int j = Mth.floor(cart.getY());
|
int j = Mth.floor(cart.getY());
|
||||||
int k = Mth.floor(cart.getZ());
|
int k = Mth.floor(cart.getZ());
|
||||||
if (world.getBlockState(new BlockPos(i, j - 1, k))
|
if (world.getBlockState(new BlockPos(i, j - 1, k))
|
||||||
.is(BlockTags.RAILS)) {
|
.is(BlockTags.RAILS)) {
|
||||||
--j;
|
--j;
|
||||||
}
|
}
|
||||||
BlockPos blockpos = new BlockPos(i, j, k);
|
BlockPos blockpos = new BlockPos(i, j, k);
|
||||||
BlockState blockstate = world.getBlockState(blockpos);
|
BlockState blockstate = world.getBlockState(blockpos);
|
||||||
if (cart.canUseRail() && blockstate.is(BlockTags.RAILS)
|
if (cart.canUseRail() && blockstate.is(BlockTags.RAILS)
|
||||||
&& blockstate.getBlock() instanceof PoweredRailBlock
|
&& blockstate.getBlock() instanceof PoweredRailBlock
|
||||||
&& ((PoweredRailBlock) blockstate.getBlock())
|
&& ((PoweredRailBlock) blockstate.getBlock())
|
||||||
.isActivatorRail()) {
|
.isActivatorRail()) {
|
||||||
if (cart.isVehicle()) {
|
if (cart.isVehicle()) {
|
||||||
cart.ejectPassengers();
|
cart.ejectPassengers();
|
||||||
}
|
}
|
||||||
|
@ -218,9 +218,8 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
|
||||||
if (passengers.isEmpty())
|
if (passengers.isEmpty())
|
||||||
return;
|
return;
|
||||||
Entity entity = passengers.get(0);
|
Entity entity = passengers.get(0);
|
||||||
if (!(entity instanceof OrientedContraptionEntity))
|
if (!(entity instanceof OrientedContraptionEntity contraption))
|
||||||
return;
|
return;
|
||||||
OrientedContraptionEntity contraption = (OrientedContraptionEntity) entity;
|
|
||||||
UUID couplingId = contraption.getCouplingId();
|
UUID couplingId = contraption.getCouplingId();
|
||||||
if (couplingId == cd.mainCartID) {
|
if (couplingId == cd.mainCartID) {
|
||||||
contraption.setCouplingId(cd.connectedCartID);
|
contraption.setCouplingId(cd.connectedCartID);
|
||||||
|
@ -394,7 +393,8 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
|
||||||
Vec3 motion;
|
Vec3 motion;
|
||||||
float yaw, pitch;
|
float yaw, pitch;
|
||||||
|
|
||||||
private StallData() {}
|
private StallData() {
|
||||||
|
}
|
||||||
|
|
||||||
StallData(AbstractMinecart entity) {
|
StallData(AbstractMinecart entity) {
|
||||||
position = entity.position();
|
position = entity.position();
|
||||||
|
|
|
@ -186,9 +186,8 @@ public class CartAssemblerBlockEntity extends SmartBlockEntity implements IDispl
|
||||||
return;
|
return;
|
||||||
Entity entity = cart.getPassengers()
|
Entity entity = cart.getPassengers()
|
||||||
.get(0);
|
.get(0);
|
||||||
if (!(entity instanceof OrientedContraptionEntity))
|
if (!(entity instanceof OrientedContraptionEntity contraption))
|
||||||
return;
|
return;
|
||||||
OrientedContraptionEntity contraption = (OrientedContraptionEntity) entity;
|
|
||||||
UUID couplingId = contraption.getCouplingId();
|
UUID couplingId = contraption.getCouplingId();
|
||||||
|
|
||||||
if (couplingId == null) {
|
if (couplingId == null) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class MinecartContraptionItem extends Item {
|
||||||
BlockState blockstate1 = world.getBlockState(blockpos.below());
|
BlockState blockstate1 = world.getBlockState(blockpos.below());
|
||||||
RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock
|
RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock
|
||||||
? ((BaseRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.below(),
|
? ((BaseRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.below(),
|
||||||
null)
|
null)
|
||||||
: RailShape.NORTH_SOUTH;
|
: RailShape.NORTH_SOUTH;
|
||||||
if (direction != Direction.DOWN && railshape1.isAscending()) {
|
if (direction != Direction.DOWN && railshape1.isAscending()) {
|
||||||
d3 = -0.4D;
|
d3 = -0.4D;
|
||||||
|
@ -174,7 +174,7 @@ public class MinecartContraptionItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addContraptionToMinecart(Level world, ItemStack itemstack, AbstractMinecart cart,
|
public static void addContraptionToMinecart(Level world, ItemStack itemstack, AbstractMinecart cart,
|
||||||
@Nullable Direction newFacing) {
|
@Nullable Direction newFacing) {
|
||||||
CompoundTag tag = itemstack.getOrCreateTag();
|
CompoundTag tag = itemstack.getOrCreateTag();
|
||||||
if (tag.contains("Contraption")) {
|
if (tag.contains("Contraption")) {
|
||||||
CompoundTag contraptionTag = tag.getCompound("Contraption");
|
CompoundTag contraptionTag = tag.getCompound("Contraption");
|
||||||
|
@ -185,7 +185,7 @@ public class MinecartContraptionItem extends Item {
|
||||||
OrientedContraptionEntity contraptionEntity =
|
OrientedContraptionEntity contraptionEntity =
|
||||||
newFacing == null ? OrientedContraptionEntity.create(world, mountedContraption, intialOrientation)
|
newFacing == null ? OrientedContraptionEntity.create(world, mountedContraption, intialOrientation)
|
||||||
: OrientedContraptionEntity.createAtYaw(world, mountedContraption, intialOrientation,
|
: OrientedContraptionEntity.createAtYaw(world, mountedContraption, intialOrientation,
|
||||||
newFacing.toYRot());
|
newFacing.toYRot());
|
||||||
|
|
||||||
contraptionEntity.startRiding(cart);
|
contraptionEntity.startRiding(cart);
|
||||||
contraptionEntity.setPos(cart.getX(), cart.getY(), cart.getZ());
|
contraptionEntity.setPos(cart.getX(), cart.getY(), cart.getZ());
|
||||||
|
@ -212,20 +212,18 @@ public class MinecartContraptionItem extends Item {
|
||||||
return;
|
return;
|
||||||
if (entity instanceof AbstractContraptionEntity)
|
if (entity instanceof AbstractContraptionEntity)
|
||||||
entity = entity.getVehicle();
|
entity = entity.getVehicle();
|
||||||
if (!(entity instanceof AbstractMinecart))
|
if (!(entity instanceof AbstractMinecart cart))
|
||||||
return;
|
return;
|
||||||
if (!entity.isAlive())
|
if (!entity.isAlive())
|
||||||
return;
|
return;
|
||||||
if (player instanceof DeployerFakePlayer dfp && dfp.onMinecartContraption)
|
if (player instanceof DeployerFakePlayer dfp && dfp.onMinecartContraption)
|
||||||
return;
|
return;
|
||||||
AbstractMinecart cart = (AbstractMinecart) entity;
|
|
||||||
Type type = cart.getMinecartType();
|
Type type = cart.getMinecartType();
|
||||||
if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST)
|
if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST)
|
||||||
return;
|
return;
|
||||||
List<Entity> passengers = cart.getPassengers();
|
List<Entity> passengers = cart.getPassengers();
|
||||||
if (passengers.isEmpty() || !(passengers.get(0) instanceof OrientedContraptionEntity))
|
if (passengers.isEmpty() || !(passengers.get(0) instanceof OrientedContraptionEntity oce))
|
||||||
return;
|
return;
|
||||||
OrientedContraptionEntity oce = (OrientedContraptionEntity) passengers.get(0);
|
|
||||||
Contraption contraption = oce.getContraption();
|
Contraption contraption = oce.getContraption();
|
||||||
|
|
||||||
if (ContraptionMovementSetting.isNoPickup(contraption.getBlocks()
|
if (ContraptionMovementSetting.isNoPickup(contraption.getBlocks()
|
||||||
|
@ -251,7 +249,7 @@ public class MinecartContraptionItem extends Item {
|
||||||
|
|
||||||
if (ContraptionPickupLimiting.isTooLargeForPickup(generatedStack.serializeNBT())) {
|
if (ContraptionPickupLimiting.isTooLargeForPickup(generatedStack.serializeNBT())) {
|
||||||
MutableComponent message = CreateLang.translateDirect("contraption.minecart_contraption_too_big")
|
MutableComponent message = CreateLang.translateDirect("contraption.minecart_contraption_too_big")
|
||||||
.withStyle(ChatFormatting.RED);
|
.withStyle(ChatFormatting.RED);
|
||||||
player.displayClientMessage(message, true);
|
player.displayClientMessage(message, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -272,17 +270,17 @@ public class MinecartContraptionItem extends Item {
|
||||||
ItemStack stack = ItemStack.EMPTY;
|
ItemStack stack = ItemStack.EMPTY;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RIDEABLE:
|
case RIDEABLE:
|
||||||
stack = AllItems.MINECART_CONTRAPTION.asStack();
|
stack = AllItems.MINECART_CONTRAPTION.asStack();
|
||||||
break;
|
break;
|
||||||
case FURNACE:
|
case FURNACE:
|
||||||
stack = AllItems.FURNACE_MINECART_CONTRAPTION.asStack();
|
stack = AllItems.FURNACE_MINECART_CONTRAPTION.asStack();
|
||||||
break;
|
break;
|
||||||
case CHEST:
|
case CHEST:
|
||||||
stack = AllItems.CHEST_MINECART_CONTRAPTION.asStack();
|
stack = AllItems.CHEST_MINECART_CONTRAPTION.asStack();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
|
|
|
@ -45,12 +45,12 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, SimpleWaterloggedBlock {
|
public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, SimpleWaterloggedBlock {
|
||||||
|
|
||||||
private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get());
|
private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get());
|
||||||
|
|
||||||
public PistonExtensionPoleBlock(Properties properties) {
|
public PistonExtensionPoleBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP).setValue(BlockStateProperties.WATERLOGGED, false));
|
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP).setValue(BlockStateProperties.WATERLOGGED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPistonPushReaction(BlockState state) {
|
public PushReaction getPistonPushReaction(BlockState state) {
|
||||||
|
@ -65,7 +65,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
|
||||||
BlockPos pistonHead = null;
|
BlockPos pistonHead = null;
|
||||||
BlockPos pistonBase = null;
|
BlockPos pistonBase = null;
|
||||||
|
|
||||||
for (int modifier : new int[] { 1, -1 }) {
|
for (int modifier : new int[]{1, -1}) {
|
||||||
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
|
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
|
||||||
modifier) {
|
modifier) {
|
||||||
BlockPos currentPos = pos.relative(direction, offset);
|
BlockPos currentPos = pos.relative(direction, offset);
|
||||||
|
@ -89,18 +89,17 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
|
||||||
|
|
||||||
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead)
|
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead)
|
||||||
.getValue(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase)
|
.getValue(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase)
|
||||||
.getValue(BlockStateProperties.FACING)) {
|
.getValue(BlockStateProperties.FACING)) {
|
||||||
|
|
||||||
final BlockPos basePos = pistonBase;
|
final BlockPos basePos = pistonBase;
|
||||||
BlockPos.betweenClosedStream(pistonBase, pistonHead)
|
BlockPos.betweenClosedStream(pistonBase, pistonHead)
|
||||||
.filter(p -> !p.equals(pos) && !p.equals(basePos))
|
.filter(p -> !p.equals(pos) && !p.equals(basePos))
|
||||||
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
||||||
worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos)
|
worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos)
|
||||||
.setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
|
.setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
|
||||||
|
|
||||||
BlockEntity be = worldIn.getBlockEntity(basePos);
|
BlockEntity be = worldIn.getBlockEntity(basePos);
|
||||||
if (be instanceof MechanicalPistonBlockEntity) {
|
if (be instanceof MechanicalPistonBlockEntity baseBE) {
|
||||||
MechanicalPistonBlockEntity baseBE = (MechanicalPistonBlockEntity) be;
|
|
||||||
baseBE.offset = 0;
|
baseBE.offset = 0;
|
||||||
baseBE.onLengthBroken();
|
baseBE.onLengthBroken();
|
||||||
}
|
}
|
||||||
|
@ -120,18 +119,18 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
|
||||||
FluidState FluidState = context.getLevel()
|
FluidState FluidState = context.getLevel()
|
||||||
.getFluidState(context.getClickedPos());
|
.getFluidState(context.getClickedPos());
|
||||||
return defaultBlockState().setValue(FACING, context.getClickedFace()
|
return defaultBlockState().setValue(FACING, context.getClickedFace()
|
||||||
.getOpposite())
|
.getOpposite())
|
||||||
.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
|
.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||||
BlockHitResult ray) {
|
BlockHitResult ray) {
|
||||||
ItemStack heldItem = player.getItemInHand(hand);
|
ItemStack heldItem = player.getItemInHand(hand);
|
||||||
|
|
||||||
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
|
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
|
||||||
if (placementHelper.matchesItem(heldItem) && !player.isShiftKeyDown())
|
if (placementHelper.matchesItem(heldItem) && !player.isShiftKeyDown())
|
||||||
return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
|
return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
|
||||||
|
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
@ -148,38 +147,38 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
|
||||||
super.createBlockStateDefinition(builder);
|
super.createBlockStateDefinition(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
|
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
||||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
public static class PlacementHelper extends PoleHelper<Direction> {
|
public static class PlacementHelper extends PoleHelper<Direction> {
|
||||||
|
|
||||||
private static final PlacementHelper instance = new PlacementHelper();
|
private static final PlacementHelper instance = new PlacementHelper();
|
||||||
|
|
||||||
public static PlacementHelper get() {
|
public static PlacementHelper get() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlacementHelper(){
|
private PlacementHelper() {
|
||||||
super(
|
super(
|
||||||
AllBlocks.PISTON_EXTENSION_POLE::has,
|
AllBlocks.PISTON_EXTENSION_POLE::has,
|
||||||
state -> state.getValue(FACING).getAxis(),
|
state -> state.getValue(FACING).getAxis(),
|
||||||
FACING
|
FACING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Predicate<ItemStack> getItemPredicate() {
|
public Predicate<ItemStack> getItemPredicate() {
|
||||||
return AllBlocks.PISTON_EXTENSION_POLE::isIn;
|
return AllBlocks.PISTON_EXTENSION_POLE::isIn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,13 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
public class PulleyBlock extends HorizontalAxisKineticBlock implements IBE<PulleyBlockEntity> {
|
public class PulleyBlock extends HorizontalAxisKineticBlock implements IBE<PulleyBlockEntity> {
|
||||||
|
|
||||||
public PulleyBlock(Properties properties) {
|
public PulleyBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onRopeBroken(Level world, BlockPos pulleyPos) {
|
private static void onRopeBroken(Level world, BlockPos pulleyPos) {
|
||||||
BlockEntity be = world.getBlockEntity(pulleyPos);
|
BlockEntity be = world.getBlockEntity(pulleyPos);
|
||||||
if (be instanceof PulleyBlockEntity) {
|
if (be instanceof PulleyBlockEntity pulley) {
|
||||||
PulleyBlockEntity pulley = (PulleyBlockEntity) be;
|
|
||||||
pulley.initialOffset = 0;
|
pulley.initialOffset = 0;
|
||||||
pulley.onLengthBroken();
|
pulley.onLengthBroken();
|
||||||
}
|
}
|
||||||
|
@ -59,122 +58,122 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements IBE<Pulle
|
||||||
worldIn.destroyBlock(pos.below(), true);
|
worldIn.destroyBlock(pos.below(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||||
BlockHitResult hit) {
|
BlockHitResult hit) {
|
||||||
if (!player.mayBuild())
|
if (!player.mayBuild())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
if (player.isShiftKeyDown())
|
if (player.isShiftKeyDown())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
if (player.getItemInHand(handIn)
|
if (player.getItemInHand(handIn)
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
withBlockEntityDo(worldIn, pos, be -> be.assembleNextTick = true);
|
withBlockEntityDo(worldIn, pos, be -> be.assembleNextTick = true);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<PulleyBlockEntity> getBlockEntityClass() {
|
public Class<PulleyBlockEntity> getBlockEntityClass() {
|
||||||
return PulleyBlockEntity.class;
|
return PulleyBlockEntity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends PulleyBlockEntity> getBlockEntityType() {
|
|
||||||
return AllBlockEntityTypes.ROPE_PULLEY.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RopeBlockBase extends Block implements SimpleWaterloggedBlock {
|
@Override
|
||||||
|
public BlockEntityType<? extends PulleyBlockEntity> getBlockEntityType() {
|
||||||
|
return AllBlockEntityTypes.ROPE_PULLEY.get();
|
||||||
|
}
|
||||||
|
|
||||||
public RopeBlockBase(Properties properties) {
|
private static class RopeBlockBase extends Block implements SimpleWaterloggedBlock {
|
||||||
super(properties);
|
|
||||||
registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
|
public RopeBlockBase(Properties properties) {
|
||||||
}
|
super(properties);
|
||||||
|
registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPistonPushReaction(BlockState state) {
|
public PushReaction getPistonPushReaction(BlockState state) {
|
||||||
return PushReaction.BLOCK;
|
return PushReaction.BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||||
Player player) {
|
Player player) {
|
||||||
return AllBlocks.ROPE_PULLEY.asStack();
|
return AllBlocks.ROPE_PULLEY.asStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (!isMoving && (!state.hasProperty(BlockStateProperties.WATERLOGGED) || !newState.hasProperty(BlockStateProperties.WATERLOGGED) || state.getValue(BlockStateProperties.WATERLOGGED) == newState.getValue(BlockStateProperties.WATERLOGGED))) {
|
if (!isMoving && (!state.hasProperty(BlockStateProperties.WATERLOGGED) || !newState.hasProperty(BlockStateProperties.WATERLOGGED) || state.getValue(BlockStateProperties.WATERLOGGED) == newState.getValue(BlockStateProperties.WATERLOGGED))) {
|
||||||
onRopeBroken(worldIn, pos.above());
|
onRopeBroken(worldIn, pos.above());
|
||||||
if (!worldIn.isClientSide) {
|
if (!worldIn.isClientSide) {
|
||||||
BlockState above = worldIn.getBlockState(pos.above());
|
BlockState above = worldIn.getBlockState(pos.above());
|
||||||
BlockState below = worldIn.getBlockState(pos.below());
|
BlockState below = worldIn.getBlockState(pos.below());
|
||||||
if (above.getBlock() instanceof RopeBlockBase)
|
if (above.getBlock() instanceof RopeBlockBase)
|
||||||
worldIn.destroyBlock(pos.above(), true);
|
worldIn.destroyBlock(pos.above(), true);
|
||||||
if (below.getBlock() instanceof RopeBlockBase)
|
if (below.getBlock() instanceof RopeBlockBase)
|
||||||
worldIn.destroyBlock(pos.below(), true);
|
worldIn.destroyBlock(pos.below(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
|
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
|
||||||
worldIn.removeBlockEntity(pos);
|
worldIn.removeBlockEntity(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
|
return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||||
builder.add(BlockStateProperties.WATERLOGGED);
|
builder.add(BlockStateProperties.WATERLOGGED);
|
||||||
super.createBlockStateDefinition(builder);
|
super.createBlockStateDefinition(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState,
|
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState,
|
||||||
LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
|
LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
|
||||||
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
||||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||||
FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos());
|
FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos());
|
||||||
return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
|
return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MagnetBlock extends RopeBlockBase {
|
public static class MagnetBlock extends RopeBlockBase {
|
||||||
|
|
||||||
public MagnetBlock(Properties properties) {
|
public MagnetBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||||
return AllShapes.PULLEY_MAGNET;
|
return AllShapes.PULLEY_MAGNET;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RopeBlock extends RopeBlockBase {
|
public static class RopeBlock extends RopeBlockBase {
|
||||||
|
|
||||||
public RopeBlock(Properties properties) {
|
public RopeBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||||
return AllShapes.FOUR_VOXEL_POLE.get(Direction.UP);
|
return AllShapes.FOUR_VOXEL_POLE.get(Direction.UP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
|
||||||
if (level.isClientSide() && mirrorParent != null)
|
if (level.isClientSide() && mirrorParent != null)
|
||||||
if (sharedMirrorContraption == null || sharedMirrorContraption.get() == null
|
if (sharedMirrorContraption == null || sharedMirrorContraption.get() == null
|
||||||
|| !sharedMirrorContraption.get()
|
|| !sharedMirrorContraption.get()
|
||||||
.isAlive()) {
|
.isAlive()) {
|
||||||
sharedMirrorContraption = null;
|
sharedMirrorContraption = null;
|
||||||
if (level.getBlockEntity(mirrorParent)instanceof PulleyBlockEntity pte && pte.movedContraption != null)
|
if (level.getBlockEntity(mirrorParent) instanceof PulleyBlockEntity pte && pte.movedContraption != null)
|
||||||
sharedMirrorContraption = new WeakReference<>(pte.movedContraption);
|
sharedMirrorContraption = new WeakReference<>(pte.movedContraption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +204,8 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
|
||||||
.getCollisionShape(level, magnetPos)
|
.getCollisionShape(level, magnetPos)
|
||||||
.isEmpty());
|
.isEmpty());
|
||||||
level.setBlock(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState()
|
level.setBlock(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState()
|
||||||
.setValue(BlockStateProperties.WATERLOGGED,
|
.setValue(BlockStateProperties.WATERLOGGED,
|
||||||
Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)),
|
Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)),
|
||||||
66);
|
66);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,7 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Vec3 toPosition(float offset) {
|
protected Vec3 toPosition(float offset) {
|
||||||
if (movedContraption.getContraption() instanceof PulleyContraption) {
|
if (movedContraption.getContraption() instanceof PulleyContraption contraption) {
|
||||||
PulleyContraption contraption = (PulleyContraption) movedContraption.getContraption();
|
|
||||||
return Vec3.atLowerCornerOf(contraption.anchor)
|
return Vec3.atLowerCornerOf(contraption.anchor)
|
||||||
.add(0, contraption.getInitialOffset() - offset, 0);
|
.add(0, contraption.getInitialOffset() - offset, 0);
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,9 @@ public class ContraptionVisual<E extends AbstractContraptionEntity> extends Abst
|
||||||
setEmbeddingMatrices(partialTick);
|
setEmbeddingMatrices(partialTick);
|
||||||
|
|
||||||
Contraption contraption = entity.getContraption();
|
Contraption contraption = entity.getContraption();
|
||||||
|
// The contraption could be null if it wasn't synced (ex. too much data)
|
||||||
|
if (contraption == null)
|
||||||
|
return;
|
||||||
|
|
||||||
setupModel(contraption);
|
setupModel(contraption);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.sync;
|
||||||
|
|
||||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
||||||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
@ -9,6 +10,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeMod;
|
import net.minecraftforge.common.ForgeMod;
|
||||||
import net.minecraftforge.network.NetworkEvent.Context;
|
import net.minecraftforge.network.NetworkEvent.Context;
|
||||||
|
|
||||||
|
@ -49,9 +51,8 @@ public class ContraptionInteractionPacket extends SimplePacketBase {
|
||||||
if (sender == null)
|
if (sender == null)
|
||||||
return;
|
return;
|
||||||
Entity entityByID = sender.level().getEntity(target);
|
Entity entityByID = sender.level().getEntity(target);
|
||||||
if (!(entityByID instanceof AbstractContraptionEntity))
|
if (!(entityByID instanceof AbstractContraptionEntity contraptionEntity))
|
||||||
return;
|
return;
|
||||||
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
|
|
||||||
AABB bb = contraptionEntity.getBoundingBox();
|
AABB bb = contraptionEntity.getBoundingBox();
|
||||||
double boundsExtra = Math.max(bb.getXsize(), bb.getYsize());
|
double boundsExtra = Math.max(bb.getXsize(), bb.getYsize());
|
||||||
double d = sender.getAttribute(ForgeMod.BLOCK_REACH.get()).getValue() + 10 + boundsExtra;
|
double d = sender.getAttribute(ForgeMod.BLOCK_REACH.get()).getValue() + 10 + boundsExtra;
|
||||||
|
|
|
@ -55,9 +55,8 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase {
|
||||||
public boolean handle(Context context) {
|
public boolean handle(Context context) {
|
||||||
context.enqueueWork(() -> {
|
context.enqueueWork(() -> {
|
||||||
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
|
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
|
||||||
if (!(entityByID instanceof AbstractContraptionEntity))
|
if (!(entityByID instanceof AbstractContraptionEntity contraptionEntity))
|
||||||
return;
|
return;
|
||||||
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
|
|
||||||
|
|
||||||
if (dismountedID != -1) {
|
if (dismountedID != -1) {
|
||||||
Entity dismountedByID = Minecraft.getInstance().level.getEntity(dismountedID);
|
Entity dismountedByID = Minecraft.getInstance().level.getEntity(dismountedID);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.client.model.data.ModelData;
|
import net.minecraftforge.client.model.data.ModelData;
|
||||||
|
|
||||||
public class CopycatBarsModel extends CopycatModel {
|
public class CopycatBarsModel extends CopycatModel {
|
||||||
|
@ -29,7 +30,7 @@ public class CopycatBarsModel extends CopycatModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<BakedQuad> getCroppedQuads(BlockState state, Direction side, RandomSource rand, BlockState material,
|
protected List<BakedQuad> getCroppedQuads(BlockState state, Direction side, RandomSource rand, BlockState material,
|
||||||
ModelData wrappedData, RenderType renderType) {
|
ModelData wrappedData, RenderType renderType) {
|
||||||
BakedModel model = getModelOf(material);
|
BakedModel model = getModelOf(material);
|
||||||
List<BakedQuad> superQuads = originalModel.getQuads(state, side, rand, wrappedData, renderType);
|
List<BakedQuad> superQuads = originalModel.getQuads(state, side, rand, wrappedData, renderType);
|
||||||
TextureAtlasSprite targetSprite = model.getParticleIcon(wrappedData);
|
TextureAtlasSprite targetSprite = model.getParticleIcon(wrappedData);
|
||||||
|
@ -39,8 +40,7 @@ public class CopycatBarsModel extends CopycatModel {
|
||||||
|
|
||||||
if (side != null && (vertical || side.getAxis() == Axis.Y)) {
|
if (side != null && (vertical || side.getAxis() == Axis.Y)) {
|
||||||
List<BakedQuad> templateQuads = model.getQuads(material, null, rand, wrappedData, renderType);
|
List<BakedQuad> templateQuads = model.getQuads(material, null, rand, wrappedData, renderType);
|
||||||
for (int i = 0; i < templateQuads.size(); i++) {
|
for (BakedQuad quad : templateQuads) {
|
||||||
BakedQuad quad = templateQuads.get(i);
|
|
||||||
if (quad.getDirection() != Direction.UP)
|
if (quad.getDirection() != Direction.UP)
|
||||||
continue;
|
continue;
|
||||||
targetSprite = quad.getSprite();
|
targetSprite = quad.getSprite();
|
||||||
|
@ -53,8 +53,7 @@ public class CopycatBarsModel extends CopycatModel {
|
||||||
|
|
||||||
List<BakedQuad> quads = new ArrayList<>();
|
List<BakedQuad> quads = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < superQuads.size(); i++) {
|
for (BakedQuad quad : superQuads) {
|
||||||
BakedQuad quad = superQuads.get(i);
|
|
||||||
TextureAtlasSprite original = quad.getSprite();
|
TextureAtlasSprite original = quad.getSprite();
|
||||||
BakedQuad newQuad = BakedQuadHelper.clone(quad);
|
BakedQuad newQuad = BakedQuadHelper.clone(quad);
|
||||||
int[] vertexData = newQuad.getVertices();
|
int[] vertexData = newQuad.getVertices();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEntity entity, float yaw, float pitch,
|
public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEntity entity, float yaw, float pitch,
|
||||||
float pt, float p_225628_8_, float p_225628_9_, float p_225628_10_) {
|
float pt, float p_225628_8_, float p_225628_9_, float p_225628_10_) {
|
||||||
if (entity.getPose() == Pose.SLEEPING)
|
if (entity.getPose() == Pose.SLEEPING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -39,13 +39,12 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
||||||
return;
|
return;
|
||||||
|
|
||||||
M entityModel = getParentModel();
|
M entityModel = getParentModel();
|
||||||
if (!(entityModel instanceof HumanoidModel))
|
if (!(entityModel instanceof HumanoidModel<?> model))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HumanoidModel<?> model = (HumanoidModel<?>) entityModel;
|
|
||||||
VertexConsumer vc = buffer.getBuffer(Sheets.cutoutBlockSheet());
|
VertexConsumer vc = buffer.getBuffer(Sheets.cutoutBlockSheet());
|
||||||
BlockState renderedState = item.getBlock().defaultBlockState()
|
BlockState renderedState = item.getBlock().defaultBlockState()
|
||||||
.setValue(BacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
|
.setValue(BacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
|
||||||
SuperByteBuffer backtank = CachedBuffers.block(renderedState);
|
SuperByteBuffer backtank = CachedBuffers.block(renderedState);
|
||||||
SuperByteBuffer cogs = CachedBuffers.partial(BacktankRenderer.getCogsModel(renderedState), renderedState);
|
SuperByteBuffer cogs = CachedBuffers.partial(BacktankRenderer.getCogsModel(renderedState), renderedState);
|
||||||
SuperByteBuffer nob = CachedBuffers.partial(BacktankRenderer.getShaftModel(renderedState), renderedState);
|
SuperByteBuffer nob = CachedBuffers.partial(BacktankRenderer.getShaftModel(renderedState), renderedState);
|
||||||
|
@ -86,11 +85,10 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
||||||
registerOn(renderer);
|
registerOn(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public static void registerOn(EntityRenderer<?> entityRenderer) {
|
public static void registerOn(EntityRenderer<?> entityRenderer) {
|
||||||
if (!(entityRenderer instanceof LivingEntityRenderer))
|
if (!(entityRenderer instanceof LivingEntityRenderer<?, ?> livingRenderer))
|
||||||
return;
|
return;
|
||||||
LivingEntityRenderer<?, ?> livingRenderer = (LivingEntityRenderer<?, ?>) entityRenderer;
|
|
||||||
if (!(livingRenderer.getModel() instanceof HumanoidModel))
|
if (!(livingRenderer.getModel() instanceof HumanoidModel))
|
||||||
return;
|
return;
|
||||||
BacktankArmorLayer<?, ?> layer = new BacktankArmorLayer<>(livingRenderer);
|
BacktankArmorLayer<?, ?> layer = new BacktankArmorLayer<>(livingRenderer);
|
||||||
|
|
|
@ -77,8 +77,7 @@ public class DivingBootsItem extends BaseArmorItem {
|
||||||
return false;
|
return false;
|
||||||
if (entity.getPose() == Pose.SWIMMING)
|
if (entity.getPose() == Pose.SWIMMING)
|
||||||
return false;
|
return false;
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player playerEntity) {
|
||||||
Player playerEntity = (Player) entity;
|
|
||||||
if (playerEntity.getAbilities().flying)
|
if (playerEntity.getAbilities().flying)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.client.particle.SpriteSet;
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
import net.minecraft.core.particles.ParticleOptions;
|
||||||
import net.minecraft.core.particles.ParticleType;
|
import net.minecraft.core.particles.ParticleType;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@ -22,12 +23,13 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
public abstract class BasicParticleData<T extends Particle> implements ParticleOptions, ICustomParticleDataWithSprite<BasicParticleData<T>> {
|
public abstract class BasicParticleData<T extends Particle> implements ParticleOptions, ICustomParticleDataWithSprite<BasicParticleData<T>> {
|
||||||
|
|
||||||
public BasicParticleData() { }
|
public BasicParticleData() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Deserializer<BasicParticleData<T>> getDeserializer() {
|
public Deserializer<BasicParticleData<T>> getDeserializer() {
|
||||||
BasicParticleData<T> data = this;
|
BasicParticleData<T> data = this;
|
||||||
return new ParticleOptions.Deserializer<BasicParticleData<T>>() {
|
return new ParticleOptions.Deserializer<>() {
|
||||||
@Override
|
@Override
|
||||||
public BasicParticleData<T> fromCommand(ParticleType<BasicParticleData<T>> arg0, StringReader reader) {
|
public BasicParticleData<T> fromCommand(ParticleType<BasicParticleData<T>> arg0, StringReader reader) {
|
||||||
return data;
|
return data;
|
||||||
|
@ -56,7 +58,7 @@ public abstract class BasicParticleData<T extends Particle> implements ParticleO
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public ParticleEngine.SpriteParticleRegistration<BasicParticleData<T>> getMetaFactory() {
|
public ParticleEngine.SpriteParticleRegistration<BasicParticleData<T>> getMetaFactory() {
|
||||||
return animatedSprite -> (data, worldIn, x, y, z, vx, vy, vz) ->
|
return animatedSprite -> (data, worldIn, x, y, z, vx, vy, vz) ->
|
||||||
getBasicFactory().makeParticle(worldIn, x, y, z, vx, vy, vz, animatedSprite);
|
getBasicFactory().makeParticle(worldIn, x, y, z, vx, vy, vz, animatedSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,5 +67,6 @@ public abstract class BasicParticleData<T extends Particle> implements ParticleO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNetwork(FriendlyByteBuf buffer) { }
|
public void writeToNetwork(FriendlyByteBuf buffer) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.simibubi.create.content.equipment.blueprint;
|
package com.simibubi.create.content.equipment.blueprint;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
import net.minecraftforge.network.NetworkEvent.Context;
|
import net.minecraftforge.network.NetworkEvent.Context;
|
||||||
|
|
||||||
public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase {
|
public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase {
|
||||||
|
@ -29,12 +31,11 @@ public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase {
|
||||||
ServerPlayer player = context.getSender();
|
ServerPlayer player = context.getSender();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
if (player.containerMenu instanceof BlueprintMenu) {
|
if (player.containerMenu instanceof BlueprintMenu c) {
|
||||||
BlueprintMenu c = (BlueprintMenu) player.containerMenu;
|
|
||||||
player.level()
|
player.level()
|
||||||
.getRecipeManager()
|
.getRecipeManager()
|
||||||
.byKey(recipeID)
|
.byKey(recipeID)
|
||||||
.ifPresent(r -> BlueprintItem.assignCompleteRecipe(c.player.level(), c.ghostInventory, r));
|
.ifPresent(r -> BlueprintItem.assignCompleteRecipe(c.player.level(), c.ghostInventory, r));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -173,15 +173,15 @@ public class BlueprintEntity extends HangingEntity
|
||||||
Axis axis = direction.getAxis();
|
Axis axis = direction.getAxis();
|
||||||
if (size == 2)
|
if (size == 2)
|
||||||
pos = pos.add(Vec3.atLowerCornerOf(axis.isHorizontal() ? direction.getCounterClockWise()
|
pos = pos.add(Vec3.atLowerCornerOf(axis.isHorizontal() ? direction.getCounterClockWise()
|
||||||
.getNormal()
|
.getNormal()
|
||||||
: verticalOrientation.getClockWise()
|
: verticalOrientation.getClockWise()
|
||||||
.getNormal())
|
.getNormal())
|
||||||
.scale(0.5))
|
.scale(0.5))
|
||||||
.add(Vec3
|
.add(Vec3
|
||||||
.atLowerCornerOf(axis.isHorizontal() ? Direction.UP.getNormal()
|
.atLowerCornerOf(axis.isHorizontal() ? Direction.UP.getNormal()
|
||||||
: direction == Direction.UP ? verticalOrientation.getNormal()
|
: direction == Direction.UP ? verticalOrientation.getNormal()
|
||||||
: verticalOrientation.getOpposite()
|
: verticalOrientation.getOpposite()
|
||||||
.getNormal())
|
.getNormal())
|
||||||
.scale(0.5));
|
.scale(0.5));
|
||||||
|
|
||||||
d1 = pos.x;
|
d1 = pos.x;
|
||||||
|
@ -193,14 +193,14 @@ public class BlueprintEntity extends HangingEntity
|
||||||
double d6 = (double) this.getWidth();
|
double d6 = (double) this.getWidth();
|
||||||
Direction.Axis direction$axis = this.direction.getAxis();
|
Direction.Axis direction$axis = this.direction.getAxis();
|
||||||
switch (direction$axis) {
|
switch (direction$axis) {
|
||||||
case X:
|
case X:
|
||||||
d4 = 1.0D;
|
d4 = 1.0D;
|
||||||
break;
|
break;
|
||||||
case Y:
|
case Y:
|
||||||
d5 = 1.0D;
|
d5 = 1.0D;
|
||||||
break;
|
break;
|
||||||
case Z:
|
case Z:
|
||||||
d6 = 1.0D;
|
d6 = 1.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
d4 = d4 / 32.0D;
|
d4 = d4 / 32.0D;
|
||||||
|
@ -225,7 +225,7 @@ public class BlueprintEntity extends HangingEntity
|
||||||
BlockPos blockpos = this.pos.relative(this.direction.getOpposite());
|
BlockPos blockpos = this.pos.relative(this.direction.getOpposite());
|
||||||
Direction upDirection = direction.getAxis()
|
Direction upDirection = direction.getAxis()
|
||||||
.isHorizontal() ? Direction.UP
|
.isHorizontal() ? Direction.UP
|
||||||
: direction == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite();
|
: direction == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite();
|
||||||
Direction newDirection = direction.getAxis()
|
Direction newDirection = direction.getAxis()
|
||||||
.isVertical() ? verticalOrientation.getClockWise() : direction.getCounterClockWise();
|
.isVertical() ? verticalOrientation.getClockWise() : direction.getCounterClockWise();
|
||||||
BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos();
|
BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos();
|
||||||
|
@ -262,10 +262,9 @@ public class BlueprintEntity extends HangingEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean skipAttackInteraction(Entity source) {
|
public boolean skipAttackInteraction(Entity source) {
|
||||||
if (!(source instanceof Player) || level().isClientSide)
|
if (!(source instanceof Player player) || level().isClientSide)
|
||||||
return super.skipAttackInteraction(source);
|
return super.skipAttackInteraction(source);
|
||||||
|
|
||||||
Player player = (Player) source;
|
|
||||||
double attrib = player.getAttribute(ForgeMod.BLOCK_REACH.get())
|
double attrib = player.getAttribute(ForgeMod.BLOCK_REACH.get())
|
||||||
.getValue() + (player.isCreative() ? 0 : -0.5F);
|
.getValue() + (player.isCreative() ? 0 : -0.5F);
|
||||||
|
|
||||||
|
@ -297,8 +296,7 @@ public class BlueprintEntity extends HangingEntity
|
||||||
return;
|
return;
|
||||||
|
|
||||||
playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F);
|
playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F);
|
||||||
if (p_110128_1_ instanceof Player) {
|
if (p_110128_1_ instanceof Player playerentity) {
|
||||||
Player playerentity = (Player) p_110128_1_;
|
|
||||||
if (playerentity.getAbilities().instabuild)
|
if (playerentity.getAbilities().instabuild)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +327,7 @@ public class BlueprintEntity extends HangingEntity
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void lerpTo(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_,
|
public void lerpTo(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_,
|
||||||
int p_180426_9_, boolean p_180426_10_) {
|
int p_180426_9_, boolean p_180426_10_) {
|
||||||
BlockPos blockpos =
|
BlockPos blockpos =
|
||||||
this.pos.offset(BlockPos.containing(p_180426_1_ - this.getX(), p_180426_3_ - this.getY(), p_180426_5_ - this.getZ()));
|
this.pos.offset(BlockPos.containing(p_180426_1_ - this.getX(), p_180426_3_ - this.getY(), p_180426_5_ - this.getZ()));
|
||||||
this.setPos((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ());
|
this.setPos((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ());
|
||||||
|
@ -372,7 +370,8 @@ public class BlueprintEntity extends HangingEntity
|
||||||
Map<Integer, ItemStack> craftingGrid = new HashMap<>();
|
Map<Integer, ItemStack> craftingGrid = new HashMap<>();
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
|
|
||||||
Search: for (int i = 0; i < 9; i++) {
|
Search:
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
FilterItemStack requestedItem = FilterItemStack.of(items.getStackInSlot(i));
|
FilterItemStack requestedItem = FilterItemStack.of(items.getStackInSlot(i));
|
||||||
if (requestedItem.isEmpty()) {
|
if (requestedItem.isEmpty()) {
|
||||||
craftingGrid.put(i, ItemStack.EMPTY);
|
craftingGrid.put(i, ItemStack.EMPTY);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.simibubi.create.content.equipment.blueprint;
|
package com.simibubi.create.content.equipment.blueprint;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.content.logistics.filter.AttributeFilterMenu.WhitelistMode;
|
import com.simibubi.create.content.logistics.filter.AttributeFilterMenu.WhitelistMode;
|
||||||
import com.simibubi.create.content.logistics.filter.FilterItem;
|
import com.simibubi.create.content.logistics.filter.FilterItem;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
||||||
|
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
|
@ -26,12 +29,11 @@ import net.minecraft.world.item.crafting.Ingredient.TagValue;
|
||||||
import net.minecraft.world.item.crafting.Ingredient.Value;
|
import net.minecraft.world.item.crafting.Ingredient.Value;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
import net.minecraftforge.common.crafting.IShapedRecipe;
|
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||||
import net.minecraftforge.common.crafting.MultiItemValue;
|
import net.minecraftforge.common.crafting.MultiItemValue;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class BlueprintItem extends Item {
|
public class BlueprintItem extends Item {
|
||||||
|
|
||||||
public BlueprintItem(Properties p_i48487_1_) {
|
public BlueprintItem(Properties p_i48487_1_) {
|
||||||
|
@ -44,14 +46,14 @@ public class BlueprintItem extends Item {
|
||||||
Player player = ctx.getPlayer();
|
Player player = ctx.getPlayer();
|
||||||
ItemStack stack = ctx.getItemInHand();
|
ItemStack stack = ctx.getItemInHand();
|
||||||
BlockPos pos = ctx.getClickedPos()
|
BlockPos pos = ctx.getClickedPos()
|
||||||
.relative(face);
|
.relative(face);
|
||||||
|
|
||||||
if (player != null && !player.mayUseItemAt(pos, face, stack))
|
if (player != null && !player.mayUseItemAt(pos, face, stack))
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
|
|
||||||
Level world = ctx.getLevel();
|
Level world = ctx.getLevel();
|
||||||
HangingEntity hangingentity = new BlueprintEntity(world, pos, face, face.getAxis()
|
HangingEntity hangingentity = new BlueprintEntity(world, pos, face, face.getAxis()
|
||||||
.isHorizontal() ? Direction.DOWN : ctx.getHorizontalDirection());
|
.isHorizontal() ? Direction.DOWN : ctx.getHorizontalDirection());
|
||||||
CompoundTag compoundnbt = stack.getTag();
|
CompoundTag compoundnbt = stack.getTag();
|
||||||
|
|
||||||
if (compoundnbt != null)
|
if (compoundnbt != null)
|
||||||
|
@ -79,12 +81,11 @@ public class BlueprintItem extends Item {
|
||||||
inv.setStackInSlot(i, ItemStack.EMPTY);
|
inv.setStackInSlot(i, ItemStack.EMPTY);
|
||||||
inv.setStackInSlot(9, recipe.getResultItem(level.registryAccess()));
|
inv.setStackInSlot(9, recipe.getResultItem(level.registryAccess()));
|
||||||
|
|
||||||
if (recipe instanceof IShapedRecipe) {
|
if (recipe instanceof IShapedRecipe<?> shapedRecipe) {
|
||||||
IShapedRecipe<?> shapedRecipe = (IShapedRecipe<?>) recipe;
|
|
||||||
for (int row = 0; row < shapedRecipe.getRecipeHeight(); row++)
|
for (int row = 0; row < shapedRecipe.getRecipeHeight(); row++)
|
||||||
for (int col = 0; col < shapedRecipe.getRecipeWidth(); col++)
|
for (int col = 0; col < shapedRecipe.getRecipeWidth(); col++)
|
||||||
inv.setStackInSlot(row * 3 + col,
|
inv.setStackInSlot(row * 3 + col,
|
||||||
convertIngredientToFilter(ingredients.get(row * shapedRecipe.getRecipeWidth() + col)));
|
convertIngredientToFilter(ingredients.get(row * shapedRecipe.getRecipeWidth() + col)));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < ingredients.size(); i++)
|
for (int i = 0; i < ingredients.size(); i++)
|
||||||
inv.setStackInSlot(i, convertIngredientToFilter(ingredients.get(i)));
|
inv.setStackInSlot(i, convertIngredientToFilter(ingredients.get(i)));
|
||||||
|
@ -105,7 +106,7 @@ public class BlueprintItem extends Item {
|
||||||
for (int i = 0; i < acceptedItems.length; i++)
|
for (int i = 0; i < acceptedItems.length; i++)
|
||||||
filterItems.setStackInSlot(i, convertIItemListToFilter(acceptedItems[i]));
|
filterItems.setStackInSlot(i, convertIItemListToFilter(acceptedItems[i]));
|
||||||
result.getOrCreateTag()
|
result.getOrCreateTag()
|
||||||
.put("Items", filterItems.serializeNBT());
|
.put("Items", filterItems.serializeNBT());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,13 +121,13 @@ public class BlueprintItem extends Item {
|
||||||
ResourceLocation resourcelocation = new ResourceLocation(GsonHelper.getAsString(itemList.serialize(), "tag"));
|
ResourceLocation resourcelocation = new ResourceLocation(GsonHelper.getAsString(itemList.serialize(), "tag"));
|
||||||
ItemStack filterItem = AllItems.ATTRIBUTE_FILTER.asStack();
|
ItemStack filterItem = AllItems.ATTRIBUTE_FILTER.asStack();
|
||||||
filterItem.getOrCreateTag()
|
filterItem.getOrCreateTag()
|
||||||
.putInt("WhitelistMode", WhitelistMode.WHITELIST_DISJ.ordinal());
|
.putInt("WhitelistMode", WhitelistMode.WHITELIST_DISJ.ordinal());
|
||||||
ListTag attributes = new ListTag();
|
ListTag attributes = new ListTag();
|
||||||
CompoundTag compoundNBT = ItemAttribute.saveStatic(new InTagAttribute(ItemTags.create(resourcelocation)));
|
CompoundTag compoundNBT = ItemAttribute.saveStatic(new InTagAttribute(ItemTags.create(resourcelocation)));
|
||||||
compoundNBT.putBoolean("Inverted", false);
|
compoundNBT.putBoolean("Inverted", false);
|
||||||
attributes.add(compoundNBT);
|
attributes.add(compoundNBT);
|
||||||
filterItem.getOrCreateTag()
|
filterItem.getOrCreateTag()
|
||||||
.put("MatchedAttributes", attributes);
|
.put("MatchedAttributes", attributes);
|
||||||
return filterItem;
|
return filterItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.simibubi.create.content.equipment.blueprint;
|
package com.simibubi.create.content.equipment.blueprint;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.simibubi.create.AllMenuTypes;
|
import com.simibubi.create.AllMenuTypes;
|
||||||
import com.simibubi.create.content.equipment.blueprint.BlueprintEntity.BlueprintSection;
|
import com.simibubi.create.content.equipment.blueprint.BlueprintEntity.BlueprintSection;
|
||||||
import com.simibubi.create.foundation.gui.menu.GhostItemMenu;
|
import com.simibubi.create.foundation.gui.menu.GhostItemMenu;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
|
@ -18,14 +21,13 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
|
public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
|
||||||
|
|
||||||
public BlueprintMenu(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
|
public BlueprintMenu(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||||
|
@ -68,12 +70,12 @@ public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
|
||||||
ServerPlayer serverplayerentity = (ServerPlayer) player;
|
ServerPlayer serverplayerentity = (ServerPlayer) player;
|
||||||
CraftingContainer craftingInventory = new BlueprintCraftingInventory(this, ghostInventory);
|
CraftingContainer craftingInventory = new BlueprintCraftingInventory(this, ghostInventory);
|
||||||
Optional<CraftingRecipe> optional = player.getServer()
|
Optional<CraftingRecipe> optional = player.getServer()
|
||||||
.getRecipeManager()
|
.getRecipeManager()
|
||||||
.getRecipeFor(RecipeType.CRAFTING, craftingInventory, player.getCommandSenderWorld());
|
.getRecipeFor(RecipeType.CRAFTING, craftingInventory, player.getCommandSenderWorld());
|
||||||
|
|
||||||
if (!optional.isPresent()) {
|
if (!optional.isPresent()) {
|
||||||
if (ghostInventory.getStackInSlot(9)
|
if (ghostInventory.getStackInSlot(9)
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!contentHolder.inferredIcon)
|
if (!contentHolder.inferredIcon)
|
||||||
return;
|
return;
|
||||||
|
@ -90,7 +92,7 @@ public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
|
||||||
contentHolder.inferredIcon = true;
|
contentHolder.inferredIcon = true;
|
||||||
ItemStack toSend = itemstack.copy();
|
ItemStack toSend = itemstack.copy();
|
||||||
toSend.getOrCreateTag()
|
toSend.getOrCreateTag()
|
||||||
.putBoolean("InferredFromRecipe", true);
|
.putBoolean("InferredFromRecipe", true);
|
||||||
serverplayerentity.connection.send(new ClientboundContainerSetSlotPacket(containerId, incrementStateId(), 36 + 9, toSend));
|
serverplayerentity.connection.send(new ClientboundContainerSetSlotPacket(containerId, incrementStateId(), 36 + 9, toSend));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,9 +101,9 @@ public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
|
||||||
if (slotId == 36 + 9) {
|
if (slotId == 36 + 9) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
contentHolder.inferredIcon = stack.getTag()
|
contentHolder.inferredIcon = stack.getTag()
|
||||||
.getBoolean("InferredFromRecipe");
|
.getBoolean("InferredFromRecipe");
|
||||||
stack.getTag()
|
stack.getTag()
|
||||||
.remove("InferredFromRecipe");
|
.remove("InferredFromRecipe");
|
||||||
} else
|
} else
|
||||||
contentHolder.inferredIcon = false;
|
contentHolder.inferredIcon = false;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +131,8 @@ public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
|
||||||
int entityID = extraData.readVarInt();
|
int entityID = extraData.readVarInt();
|
||||||
int section = extraData.readVarInt();
|
int section = extraData.readVarInt();
|
||||||
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
|
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
|
||||||
if (!(entityByID instanceof BlueprintEntity))
|
if (!(entityByID instanceof BlueprintEntity blueprintEntity))
|
||||||
return null;
|
return null;
|
||||||
BlueprintEntity blueprintEntity = (BlueprintEntity) entityByID;
|
|
||||||
BlueprintSection blueprintSection = blueprintEntity.getSection(section);
|
BlueprintSection blueprintSection = blueprintEntity.getSection(section);
|
||||||
return blueprintSection;
|
return blueprintSection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,16 @@ import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
||||||
import com.simibubi.create.content.logistics.packager.InventorySummary;
|
import com.simibubi.create.content.logistics.packager.InventorySummary;
|
||||||
import com.simibubi.create.content.logistics.tableCloth.BlueprintOverlayShopContext;
|
import com.simibubi.create.content.logistics.tableCloth.BlueprintOverlayShopContext;
|
||||||
import com.simibubi.create.content.logistics.tableCloth.TableClothBlockEntity;
|
|
||||||
import com.simibubi.create.content.logistics.tableCloth.ShoppingListItem.ShoppingList;
|
import com.simibubi.create.content.logistics.tableCloth.ShoppingListItem.ShoppingList;
|
||||||
|
import com.simibubi.create.content.logistics.tableCloth.TableClothBlockEntity;
|
||||||
import com.simibubi.create.content.trains.track.TrackPlacement.PlacementInfo;
|
import com.simibubi.create.content.trains.track.TrackPlacement.PlacementInfo;
|
||||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||||
|
|
||||||
import net.createmod.catnip.gui.element.GuiGameElement;
|
|
||||||
import net.createmod.catnip.animation.AnimationTickHolder;
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
import net.createmod.catnip.data.Couple;
|
import net.createmod.catnip.data.Couple;
|
||||||
import net.createmod.catnip.data.Iterate;
|
import net.createmod.catnip.data.Iterate;
|
||||||
import net.createmod.catnip.data.Pair;
|
import net.createmod.catnip.data.Pair;
|
||||||
|
import net.createmod.catnip.gui.element.GuiGameElement;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
@ -36,7 +36,6 @@ import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.CraftingContainer;
|
import net.minecraft.world.inventory.CraftingContainer;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
@ -49,6 +48,7 @@ import net.minecraft.world.level.GameType;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.HitResult.Type;
|
import net.minecraft.world.phys.HitResult.Type;
|
||||||
|
|
||||||
import net.minecraftforge.client.gui.overlay.ForgeGui;
|
import net.minecraftforge.client.gui.overlay.ForgeGui;
|
||||||
import net.minecraftforge.client.gui.overlay.IGuiOverlay;
|
import net.minecraftforge.client.gui.overlay.IGuiOverlay;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
@ -92,10 +92,9 @@ public class BlueprintOverlayRenderer {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EntityHitResult entityRay = (EntityHitResult) mouseOver;
|
EntityHitResult entityRay = (EntityHitResult) mouseOver;
|
||||||
if (!(entityRay.getEntity() instanceof BlueprintEntity))
|
if (!(entityRay.getEntity() instanceof BlueprintEntity blueprintEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlueprintEntity blueprintEntity = (BlueprintEntity) entityRay.getEntity();
|
|
||||||
BlueprintSection sectionAt = blueprintEntity.getSectionAt(entityRay.getLocation()
|
BlueprintSection sectionAt = blueprintEntity.getSectionAt(entityRay.getLocation()
|
||||||
.subtract(blueprintEntity.position()));
|
.subtract(blueprintEntity.position()));
|
||||||
|
|
||||||
|
@ -151,7 +150,7 @@ public class BlueprintOverlayRenderer {
|
||||||
shopContext = new BlueprintOverlayShopContext(false, dce.getStockLevelForTrade(list), alreadyPurchased);
|
shopContext = new BlueprintOverlayShopContext(false, dce.getStockLevelForTrade(list), alreadyPurchased);
|
||||||
|
|
||||||
ingredients.add(Pair.of(dce.getPaymentItem()
|
ingredients.add(Pair.of(dce.getPaymentItem()
|
||||||
.copyWithCount(dce.getPaymentAmount()),
|
.copyWithCount(dce.getPaymentAmount()),
|
||||||
!dce.getPaymentItem()
|
!dce.getPaymentItem()
|
||||||
.isEmpty() && shopContext.stockLevel() > shopContext.purchases()));
|
.isEmpty() && shopContext.stockLevel() > shopContext.purchases()));
|
||||||
for (BigItemStack entry : dce.requestData.encodedRequest.stacks())
|
for (BigItemStack entry : dce.requestData.encodedRequest.stacks())
|
||||||
|
@ -241,7 +240,8 @@ public class BlueprintOverlayRenderer {
|
||||||
newlyAdded.clear();
|
newlyAdded.clear();
|
||||||
newlyMissing.clear();
|
newlyMissing.clear();
|
||||||
|
|
||||||
Search: for (int i = 0; i < 9; i++) {
|
Search:
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
FilterItemStack requestedItem = FilterItemStack.of(items.getStackInSlot(i));
|
FilterItemStack requestedItem = FilterItemStack.of(items.getStackInSlot(i));
|
||||||
if (requestedItem.isEmpty()) {
|
if (requestedItem.isEmpty()) {
|
||||||
craftingGrid.put(i, ItemStack.EMPTY);
|
craftingGrid.put(i, ItemStack.EMPTY);
|
||||||
|
@ -351,7 +351,7 @@ public class BlueprintOverlayRenderer {
|
||||||
AllGuiTextures.TRADE_OVERLAY.render(graphics, width / 2 - 48, y - 19);
|
AllGuiTextures.TRADE_OVERLAY.render(graphics, width / 2 - 48, y - 19);
|
||||||
if (shopContext.purchases() > 0) {
|
if (shopContext.purchases() > 0) {
|
||||||
graphics.renderItem(AllItems.SHOPPING_LIST.asStack(), width / 2 + 20, y - 20);
|
graphics.renderItem(AllItems.SHOPPING_LIST.asStack(), width / 2 + 20, y - 20);
|
||||||
graphics.drawString(mc.font, Component.literal("x" + shopContext.purchases()), width / 2 + 20 + 16,
|
graphics.drawString(mc.font, Component.literal("x" + shopContext.purchases()), width / 2 + 20 + 16,
|
||||||
y - 20 + 4, 0xff_eeeeee, true);
|
y - 20 + 4, 0xff_eeeeee, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ public class BlueprintOverlayRenderer {
|
||||||
if ((gui.getGuiTicks() / 40) % cycle != i)
|
if ((gui.getGuiTicks() / 40) % cycle != i)
|
||||||
continue;
|
continue;
|
||||||
graphics.renderComponentTooltip(gui.getFont(), tooltipLines, mc.getWindow()
|
graphics.renderComponentTooltip(gui.getFont(), tooltipLines, mc.getWindow()
|
||||||
.getGuiScaledWidth(),
|
.getGuiScaledWidth(),
|
||||||
mc.getWindow()
|
mc.getWindow()
|
||||||
.getGuiScaledHeight());
|
.getGuiScaledHeight());
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ public class BlueprintOverlayRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawItemStack(GuiGraphics graphics, Minecraft mc, int x, int y, ItemStack itemStack,
|
public static void drawItemStack(GuiGraphics graphics, Minecraft mc, int x, int y, ItemStack itemStack,
|
||||||
String count) {
|
String count) {
|
||||||
if (itemStack.getItem() instanceof FilterItem) {
|
if (itemStack.getItem() instanceof FilterItem) {
|
||||||
int step = AnimationTickHolder.getTicks(mc.level) / 10;
|
int step = AnimationTickHolder.getTicks(mc.level) / 10;
|
||||||
ItemStack[] itemsMatchingFilter = getItemsMatchingFilter(itemStack);
|
ItemStack[] itemsMatchingFilter = getItemsMatchingFilter(itemStack);
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package com.simibubi.create.content.equipment.extendoGrip;
|
package com.simibubi.create.content.equipment.extendoGrip;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -9,6 +13,7 @@ import com.simibubi.create.content.equipment.armor.BacktankUtil;
|
||||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||||
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
|
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
|
||||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||||
|
|
||||||
import net.createmod.catnip.animation.AnimationTickHolder;
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
@ -29,6 +34,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.HitResult.Type;
|
import net.minecraft.world.phys.HitResult.Type;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.InputEvent;
|
import net.minecraftforge.client.event.InputEvent;
|
||||||
|
@ -46,10 +52,6 @@ import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@EventBusSubscriber
|
@EventBusSubscriber
|
||||||
public class ExtendoGripItem extends Item {
|
public class ExtendoGripItem extends Item {
|
||||||
public static final int MAX_DAMAGE = 200;
|
public static final int MAX_DAMAGE = 200;
|
||||||
|
@ -62,11 +64,11 @@ public class ExtendoGripItem extends Item {
|
||||||
AttributeModifier.Operation.ADDITION);
|
AttributeModifier.Operation.ADDITION);
|
||||||
|
|
||||||
private static final Supplier<Multimap<Attribute, AttributeModifier>> rangeModifier = Suppliers.memoize(() ->
|
private static final Supplier<Multimap<Attribute, AttributeModifier>> rangeModifier = Suppliers.memoize(() ->
|
||||||
// Holding an ExtendoGrip
|
// Holding an ExtendoGrip
|
||||||
ImmutableMultimap.of(ForgeMod.BLOCK_REACH.get(), singleRangeAttributeModifier));
|
ImmutableMultimap.of(ForgeMod.BLOCK_REACH.get(), singleRangeAttributeModifier));
|
||||||
private static final Supplier<Multimap<Attribute, AttributeModifier>> doubleRangeModifier = Suppliers.memoize(() ->
|
private static final Supplier<Multimap<Attribute, AttributeModifier>> doubleRangeModifier = Suppliers.memoize(() ->
|
||||||
// Holding two ExtendoGrips o.O
|
// Holding two ExtendoGrips o.O
|
||||||
ImmutableMultimap.of(ForgeMod.BLOCK_REACH.get(), doubleRangeAttributeModifier));
|
ImmutableMultimap.of(ForgeMod.BLOCK_REACH.get(), doubleRangeAttributeModifier));
|
||||||
|
|
||||||
private static DamageSource lastActiveDamageSource;
|
private static DamageSource lastActiveDamageSource;
|
||||||
|
|
||||||
|
@ -79,11 +81,9 @@ public class ExtendoGripItem extends Item {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void holdingExtendoGripIncreasesRange(LivingTickEvent event) {
|
public static void holdingExtendoGripIncreasesRange(LivingTickEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player))
|
if (!(event.getEntity() instanceof Player player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = (Player) event.getEntity();
|
|
||||||
|
|
||||||
CompoundTag persistentData = player.getPersistentData();
|
CompoundTag persistentData = player.getPersistentData();
|
||||||
boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem());
|
boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem());
|
||||||
boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem());
|
boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem());
|
||||||
|
@ -245,9 +245,8 @@ public class ExtendoGripItem extends Item {
|
||||||
if (lastActiveDamageSource == null)
|
if (lastActiveDamageSource == null)
|
||||||
return;
|
return;
|
||||||
Entity entity = lastActiveDamageSource.getDirectEntity();
|
Entity entity = lastActiveDamageSource.getDirectEntity();
|
||||||
if (!(entity instanceof Player))
|
if (!(entity instanceof Player player))
|
||||||
return;
|
return;
|
||||||
Player player = (Player) entity;
|
|
||||||
if (!isHoldingExtendoGrip(player))
|
if (!isHoldingExtendoGrip(player))
|
||||||
return;
|
return;
|
||||||
event.setStrength(event.getStrength() + 2);
|
event.setStrength(event.getStrength() + 2);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class GoggleOverlayRenderer {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HitResult objectMouseOver = mc.hitResult;
|
HitResult objectMouseOver = mc.hitResult;
|
||||||
if (!(objectMouseOver instanceof BlockHitResult)) {
|
if (!(objectMouseOver instanceof BlockHitResult result)) {
|
||||||
lastHovered = null;
|
lastHovered = null;
|
||||||
hoverTicks = 0;
|
hoverTicks = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -82,7 +82,6 @@ public class GoggleOverlayRenderer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockHitResult result = (BlockHitResult) objectMouseOver;
|
|
||||||
ClientLevel world = mc.level;
|
ClientLevel world = mc.level;
|
||||||
BlockPos pos = result.getBlockPos();
|
BlockPos pos = result.getBlockPos();
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
package com.simibubi.create.content.equipment.potatoCannon;
|
package com.simibubi.create.content.equipment.potatoCannon;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.foundation.mixin.accessor.FallingBlockEntityAccessor;
|
import com.simibubi.create.foundation.mixin.accessor.FallingBlockEntityAccessor;
|
||||||
|
|
||||||
import net.createmod.catnip.data.WorldAttached;
|
import net.createmod.catnip.data.WorldAttached;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
@ -34,17 +40,13 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.ForgeEventFactory;
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
import net.minecraftforge.event.entity.EntityTeleportEvent;
|
import net.minecraftforge.event.entity.EntityTeleportEvent;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class BuiltinPotatoProjectileTypes {
|
public class BuiltinPotatoProjectileTypes {
|
||||||
|
|
||||||
private static final GameProfile ZOMBIE_CONVERTER_NAME =
|
private static final GameProfile ZOMBIE_CONVERTER_NAME =
|
||||||
|
@ -54,206 +56,204 @@ public class BuiltinPotatoProjectileTypes {
|
||||||
|
|
||||||
public static final PotatoCannonProjectileType
|
public static final PotatoCannonProjectileType
|
||||||
|
|
||||||
FALLBACK = create("fallback").damage(0)
|
FALLBACK = create("fallback").damage(0)
|
||||||
.register(),
|
.register(),
|
||||||
|
|
||||||
POTATO = create("potato").damage(5)
|
POTATO = create("potato").damage(5)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.velocity(1.25f)
|
.velocity(1.25f)
|
||||||
.knockback(1.5f)
|
.knockback(1.5f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.onBlockHit(plantCrop(Blocks.POTATOES))
|
.onBlockHit(plantCrop(Blocks.POTATOES))
|
||||||
.registerAndAssign(Items.POTATO),
|
.registerAndAssign(Items.POTATO),
|
||||||
|
|
||||||
BAKED_POTATO = create("baked_potato").damage(5)
|
BAKED_POTATO = create("baked_potato").damage(5)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.velocity(1.25f)
|
.velocity(1.25f)
|
||||||
.knockback(0.5f)
|
.knockback(0.5f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.preEntityHit(setFire(3))
|
.preEntityHit(setFire(3))
|
||||||
.registerAndAssign(Items.BAKED_POTATO),
|
.registerAndAssign(Items.BAKED_POTATO),
|
||||||
|
|
||||||
CARROT = create("carrot").damage(4)
|
CARROT = create("carrot").damage(4)
|
||||||
.reloadTicks(12)
|
.reloadTicks(12)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.knockback(0.3f)
|
.knockback(0.3f)
|
||||||
.renderTowardMotion(140, 1)
|
.renderTowardMotion(140, 1)
|
||||||
.soundPitch(1.5f)
|
.soundPitch(1.5f)
|
||||||
.onBlockHit(plantCrop(Blocks.CARROTS))
|
.onBlockHit(plantCrop(Blocks.CARROTS))
|
||||||
.registerAndAssign(Items.CARROT),
|
.registerAndAssign(Items.CARROT),
|
||||||
|
|
||||||
GOLDEN_CARROT = create("golden_carrot").damage(12)
|
GOLDEN_CARROT = create("golden_carrot").damage(12)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.knockback(0.5f)
|
.knockback(0.5f)
|
||||||
.renderTowardMotion(140, 2)
|
.renderTowardMotion(140, 2)
|
||||||
.soundPitch(1.5f)
|
.soundPitch(1.5f)
|
||||||
.registerAndAssign(Items.GOLDEN_CARROT),
|
.registerAndAssign(Items.GOLDEN_CARROT),
|
||||||
|
|
||||||
SWEET_BERRIES = create("sweet_berry").damage(3)
|
SWEET_BERRIES = create("sweet_berry").damage(3)
|
||||||
.reloadTicks(10)
|
.reloadTicks(10)
|
||||||
.knockback(0.1f)
|
.knockback(0.1f)
|
||||||
.velocity(1.05f)
|
.velocity(1.05f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.splitInto(3)
|
.splitInto(3)
|
||||||
.soundPitch(1.25f)
|
.soundPitch(1.25f)
|
||||||
.registerAndAssign(Items.SWEET_BERRIES),
|
.registerAndAssign(Items.SWEET_BERRIES),
|
||||||
|
|
||||||
GLOW_BERRIES = create("glow_berry").damage(2)
|
GLOW_BERRIES = create("glow_berry").damage(2)
|
||||||
.reloadTicks(10)
|
.reloadTicks(10)
|
||||||
.knockback(0.05f)
|
.knockback(0.05f)
|
||||||
.velocity(1.05f)
|
.velocity(1.05f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.splitInto(2)
|
.splitInto(2)
|
||||||
.soundPitch(1.2f)
|
.soundPitch(1.2f)
|
||||||
.onEntityHit(potion(MobEffects.GLOWING, 1, 200, false))
|
.onEntityHit(potion(MobEffects.GLOWING, 1, 200, false))
|
||||||
.registerAndAssign(Items.GLOW_BERRIES),
|
.registerAndAssign(Items.GLOW_BERRIES),
|
||||||
|
|
||||||
CHOCOLATE_BERRIES = create("chocolate_berry").damage(4)
|
CHOCOLATE_BERRIES = create("chocolate_berry").damage(4)
|
||||||
.reloadTicks(10)
|
.reloadTicks(10)
|
||||||
.knockback(0.2f)
|
.knockback(0.2f)
|
||||||
.velocity(1.05f)
|
.velocity(1.05f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.splitInto(3)
|
.splitInto(3)
|
||||||
.soundPitch(1.25f)
|
.soundPitch(1.25f)
|
||||||
.registerAndAssign(AllItems.CHOCOLATE_BERRIES.get()),
|
.registerAndAssign(AllItems.CHOCOLATE_BERRIES.get()),
|
||||||
|
|
||||||
POISON_POTATO = create("poison_potato").damage(5)
|
POISON_POTATO = create("poison_potato").damage(5)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.knockback(0.05f)
|
.knockback(0.05f)
|
||||||
.velocity(1.25f)
|
.velocity(1.25f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.onEntityHit(potion(MobEffects.POISON, 1, 160, true))
|
.onEntityHit(potion(MobEffects.POISON, 1, 160, true))
|
||||||
.registerAndAssign(Items.POISONOUS_POTATO),
|
.registerAndAssign(Items.POISONOUS_POTATO),
|
||||||
|
|
||||||
CHORUS_FRUIT = create("chorus_fruit").damage(3)
|
CHORUS_FRUIT = create("chorus_fruit").damage(3)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.velocity(1.20f)
|
.velocity(1.20f)
|
||||||
.knockback(0.05f)
|
.knockback(0.05f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.onEntityHit(chorusTeleport(20))
|
.onEntityHit(chorusTeleport(20))
|
||||||
.registerAndAssign(Items.CHORUS_FRUIT),
|
.registerAndAssign(Items.CHORUS_FRUIT),
|
||||||
|
|
||||||
APPLE = create("apple").damage(5)
|
APPLE = create("apple").damage(5)
|
||||||
.reloadTicks(10)
|
.reloadTicks(10)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.knockback(0.5f)
|
.knockback(0.5f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(1.1f)
|
.soundPitch(1.1f)
|
||||||
.registerAndAssign(Items.APPLE),
|
.registerAndAssign(Items.APPLE),
|
||||||
|
|
||||||
HONEYED_APPLE = create("honeyed_apple").damage(6)
|
HONEYED_APPLE = create("honeyed_apple").damage(6)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.velocity(1.35f)
|
.velocity(1.35f)
|
||||||
.knockback(0.1f)
|
.knockback(0.1f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(1.1f)
|
.soundPitch(1.1f)
|
||||||
.onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2, 160, true))
|
.onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2, 160, true))
|
||||||
.registerAndAssign(AllItems.HONEYED_APPLE.get()),
|
.registerAndAssign(AllItems.HONEYED_APPLE.get()),
|
||||||
|
|
||||||
GOLDEN_APPLE = create("golden_apple").damage(1)
|
GOLDEN_APPLE = create("golden_apple").damage(1)
|
||||||
.reloadTicks(100)
|
.reloadTicks(100)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.knockback(0.05f)
|
.knockback(0.05f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(1.1f)
|
.soundPitch(1.1f)
|
||||||
.onEntityHit(ray -> {
|
.onEntityHit(ray -> {
|
||||||
Entity entity = ray.getEntity();
|
Entity entity = ray.getEntity();
|
||||||
Level world = entity.level();
|
Level world = entity.level();
|
||||||
|
|
||||||
if (!(entity instanceof ZombieVillager) || !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS))
|
if (!(entity instanceof ZombieVillager) || !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS))
|
||||||
return foodEffects(Foods.GOLDEN_APPLE, false).test(ray);
|
return foodEffects(Foods.GOLDEN_APPLE, false).test(ray);
|
||||||
if (world.isClientSide)
|
if (world.isClientSide)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FakePlayer dummy = ZOMBIE_CONVERTERS.get(world);
|
FakePlayer dummy = ZOMBIE_CONVERTERS.get(world);
|
||||||
dummy.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1));
|
dummy.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1));
|
||||||
((ZombieVillager) entity).mobInteract(dummy, InteractionHand.MAIN_HAND);
|
((ZombieVillager) entity).mobInteract(dummy, InteractionHand.MAIN_HAND);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.registerAndAssign(Items.GOLDEN_APPLE),
|
.registerAndAssign(Items.GOLDEN_APPLE),
|
||||||
|
|
||||||
ENCHANTED_GOLDEN_APPLE = create("enchanted_golden_apple").damage(1)
|
ENCHANTED_GOLDEN_APPLE = create("enchanted_golden_apple").damage(1)
|
||||||
.reloadTicks(100)
|
.reloadTicks(100)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.knockback(0.05f)
|
.knockback(0.05f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(1.1f)
|
.soundPitch(1.1f)
|
||||||
.onEntityHit(foodEffects(Foods.ENCHANTED_GOLDEN_APPLE, false))
|
.onEntityHit(foodEffects(Foods.ENCHANTED_GOLDEN_APPLE, false))
|
||||||
.registerAndAssign(Items.ENCHANTED_GOLDEN_APPLE),
|
.registerAndAssign(Items.ENCHANTED_GOLDEN_APPLE),
|
||||||
|
|
||||||
BEETROOT = create("beetroot").damage(2)
|
BEETROOT = create("beetroot").damage(2)
|
||||||
.reloadTicks(5)
|
.reloadTicks(5)
|
||||||
.velocity(1.6f)
|
.velocity(1.6f)
|
||||||
.knockback(0.1f)
|
.knockback(0.1f)
|
||||||
.renderTowardMotion(140, 2)
|
.renderTowardMotion(140, 2)
|
||||||
.soundPitch(1.6f)
|
.soundPitch(1.6f)
|
||||||
.registerAndAssign(Items.BEETROOT),
|
.registerAndAssign(Items.BEETROOT),
|
||||||
|
|
||||||
MELON_SLICE = create("melon_slice").damage(3)
|
MELON_SLICE = create("melon_slice").damage(3)
|
||||||
.reloadTicks(8)
|
.reloadTicks(8)
|
||||||
.knockback(0.1f)
|
.knockback(0.1f)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(1.5f)
|
.soundPitch(1.5f)
|
||||||
.registerAndAssign(Items.MELON_SLICE),
|
.registerAndAssign(Items.MELON_SLICE),
|
||||||
|
|
||||||
GLISTERING_MELON = create("glistering_melon").damage(5)
|
GLISTERING_MELON = create("glistering_melon").damage(5)
|
||||||
.reloadTicks(8)
|
.reloadTicks(8)
|
||||||
.knockback(0.1f)
|
.knockback(0.1f)
|
||||||
.velocity(1.45f)
|
.velocity(1.45f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(1.5f)
|
.soundPitch(1.5f)
|
||||||
.onEntityHit(potion(MobEffects.GLOWING, 1, 100, true))
|
.onEntityHit(potion(MobEffects.GLOWING, 1, 100, true))
|
||||||
.registerAndAssign(Items.GLISTERING_MELON_SLICE),
|
.registerAndAssign(Items.GLISTERING_MELON_SLICE),
|
||||||
|
|
||||||
MELON_BLOCK = create("melon_block").damage(8)
|
MELON_BLOCK = create("melon_block").damage(8)
|
||||||
.reloadTicks(20)
|
.reloadTicks(20)
|
||||||
.knockback(2.0f)
|
.knockback(2.0f)
|
||||||
.velocity(0.95f)
|
.velocity(0.95f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(0.9f)
|
.soundPitch(0.9f)
|
||||||
.onBlockHit(placeBlockOnGround(Blocks.MELON))
|
.onBlockHit(placeBlockOnGround(Blocks.MELON))
|
||||||
.registerAndAssign(Blocks.MELON),
|
.registerAndAssign(Blocks.MELON),
|
||||||
|
|
||||||
PUMPKIN_BLOCK = create("pumpkin_block").damage(6)
|
PUMPKIN_BLOCK = create("pumpkin_block").damage(6)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.knockback(2.0f)
|
.knockback(2.0f)
|
||||||
.velocity(0.95f)
|
.velocity(0.95f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.soundPitch(0.9f)
|
.soundPitch(0.9f)
|
||||||
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN))
|
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN))
|
||||||
.registerAndAssign(Blocks.PUMPKIN),
|
.registerAndAssign(Blocks.PUMPKIN),
|
||||||
|
|
||||||
PUMPKIN_PIE = create("pumpkin_pie").damage(7)
|
PUMPKIN_PIE = create("pumpkin_pie").damage(7)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.knockback(0.05f)
|
.knockback(0.05f)
|
||||||
.velocity(1.1f)
|
.velocity(1.1f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.sticky()
|
.sticky()
|
||||||
.soundPitch(1.1f)
|
.soundPitch(1.1f)
|
||||||
.registerAndAssign(Items.PUMPKIN_PIE),
|
.registerAndAssign(Items.PUMPKIN_PIE),
|
||||||
|
|
||||||
CAKE = create("cake").damage(8)
|
CAKE = create("cake").damage(8)
|
||||||
.reloadTicks(15)
|
.reloadTicks(15)
|
||||||
.knockback(0.1f)
|
.knockback(0.1f)
|
||||||
.velocity(1.1f)
|
.velocity(1.1f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.sticky()
|
.sticky()
|
||||||
.soundPitch(1.0f)
|
.soundPitch(1.0f)
|
||||||
.registerAndAssign(Items.CAKE),
|
.registerAndAssign(Items.CAKE),
|
||||||
|
|
||||||
BLAZE_CAKE = create("blaze_cake").damage(15)
|
BLAZE_CAKE = create("blaze_cake").damage(15)
|
||||||
.reloadTicks(20)
|
.reloadTicks(20)
|
||||||
.knockback(0.3f)
|
.knockback(0.3f)
|
||||||
.velocity(1.1f)
|
.velocity(1.1f)
|
||||||
.renderTumbling()
|
.renderTumbling()
|
||||||
.sticky()
|
.sticky()
|
||||||
.preEntityHit(setFire(12))
|
.preEntityHit(setFire(12))
|
||||||
.soundPitch(1.0f)
|
.soundPitch(1.0f)
|
||||||
.registerAndAssign(AllItems.BLAZE_CAKE.get())
|
.registerAndAssign(AllItems.BLAZE_CAKE.get());
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
private static PotatoCannonProjectileType.Builder create(String name) {
|
private static PotatoCannonProjectileType.Builder create(String name) {
|
||||||
return new PotatoCannonProjectileType.Builder(Create.asResource(name));
|
return new PotatoCannonProjectileType.Builder(Create.asResource(name));
|
||||||
|
@ -378,9 +378,8 @@ public class BuiltinPotatoProjectileTypes {
|
||||||
Level world = entity.getCommandSenderWorld();
|
Level world = entity.getCommandSenderWorld();
|
||||||
if (world.isClientSide)
|
if (world.isClientSide)
|
||||||
return true;
|
return true;
|
||||||
if (!(entity instanceof LivingEntity))
|
if (!(entity instanceof LivingEntity livingEntity))
|
||||||
return false;
|
return false;
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
|
||||||
|
|
||||||
double entityX = livingEntity.getX();
|
double entityX = livingEntity.getX();
|
||||||
double entityY = livingEntity.getY();
|
double entityY = livingEntity.getY();
|
||||||
|
@ -415,6 +414,7 @@ public class BuiltinPotatoProjectileTypes {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register() {}
|
public static void register() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.entity.IEntityAdditionalSpawnData;
|
import net.minecraftforge.entity.IEntityAdditionalSpawnData;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
@ -223,14 +224,12 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
|
||||||
if (random.nextDouble() <= recoveryChance)
|
if (random.nextDouble() <= recoveryChance)
|
||||||
recoverItem();
|
recoverItem();
|
||||||
|
|
||||||
if (!(target instanceof LivingEntity)) {
|
if (!(target instanceof LivingEntity livingentity)) {
|
||||||
playHitSound(level(), position());
|
playHitSound(level(), position());
|
||||||
kill();
|
kill();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity livingentity = (LivingEntity) target;
|
|
||||||
|
|
||||||
if (type.getReloadTicks() < 10)
|
if (type.getReloadTicks() < 10)
|
||||||
livingentity.invulnerableTime = type.getReloadTicks() + 10;
|
livingentity.invulnerableTime = type.getReloadTicks() + 10;
|
||||||
|
|
||||||
|
@ -254,8 +253,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
|
||||||
.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.ARROW_HIT_PLAYER, 0.0F));
|
.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.ARROW_HIT_PLAYER, 0.0F));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onServer && owner instanceof ServerPlayer) {
|
if (onServer && owner instanceof ServerPlayer serverplayerentity) {
|
||||||
ServerPlayer serverplayerentity = (ServerPlayer) owner;
|
|
||||||
if (!target.isAlive() && target.getType()
|
if (!target.isAlive() && target.getType()
|
||||||
.getCategory() == MobCategory.MONSTER || (target instanceof Player && target != owner))
|
.getCategory() == MobCategory.MONSTER || (target instanceof Player && target != owner))
|
||||||
AllAdvancements.POTATO_CANNON.awardTo(serverplayerentity);
|
AllAdvancements.POTATO_CANNON.awardTo(serverplayerentity);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.simibubi.create.foundation.item.CustomUseEffectsItem;
|
||||||
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
|
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
|
||||||
import com.simibubi.create.foundation.mixin.accessor.LivingEntityAccessor;
|
import com.simibubi.create.foundation.mixin.accessor.LivingEntityAccessor;
|
||||||
|
|
||||||
|
import net.createmod.catnip.data.TriState;
|
||||||
import net.createmod.catnip.math.VecHelper;
|
import net.createmod.catnip.math.VecHelper;
|
||||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -34,6 +35,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||||
|
@ -74,9 +76,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
HitResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, ClipContext.Fluid.NONE);
|
HitResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, ClipContext.Fluid.NONE);
|
||||||
if (!(raytraceresult instanceof BlockHitResult))
|
if (!(raytraceresult instanceof BlockHitResult ray))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
BlockHitResult ray = (BlockHitResult) raytraceresult;
|
|
||||||
Vec3 hitVec = ray.getLocation();
|
Vec3 hitVec = ray.getLocation();
|
||||||
|
|
||||||
AABB bb = new AABB(hitVec, hitVec).inflate(1f);
|
AABB bb = new AABB(hitVec, hitVec).inflate(1f);
|
||||||
|
@ -117,9 +118,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack finishUsingItem(ItemStack stack, Level worldIn, LivingEntity entityLiving) {
|
public ItemStack finishUsingItem(ItemStack stack, Level worldIn, LivingEntity entityLiving) {
|
||||||
if (!(entityLiving instanceof Player))
|
if (!(entityLiving instanceof Player player))
|
||||||
return stack;
|
return stack;
|
||||||
Player player = (Player) entityLiving;
|
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
if (tag.contains("Polishing")) {
|
if (tag.contains("Polishing")) {
|
||||||
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
|
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
|
||||||
|
@ -128,8 +128,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
|
||||||
|
|
||||||
if (worldIn.isClientSide) {
|
if (worldIn.isClientSide) {
|
||||||
spawnParticles(entityLiving.getEyePosition(1)
|
spawnParticles(entityLiving.getEyePosition(1)
|
||||||
.add(entityLiving.getLookAngle()
|
.add(entityLiving.getLookAngle()
|
||||||
.scale(.5f)),
|
.scale(.5f)),
|
||||||
toPolish, worldIn);
|
toPolish, worldIn);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
@ -159,9 +159,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseUsing(ItemStack stack, Level worldIn, LivingEntity entityLiving, int timeLeft) {
|
public void releaseUsing(ItemStack stack, Level worldIn, LivingEntity entityLiving, int timeLeft) {
|
||||||
if (!(entityLiving instanceof Player))
|
if (!(entityLiving instanceof Player player))
|
||||||
return;
|
return;
|
||||||
Player player = (Player) entityLiving;
|
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
if (tag.contains("Polishing")) {
|
if (tag.contains("Polishing")) {
|
||||||
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
|
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
|
||||||
|
@ -208,9 +207,9 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean shouldTriggerUseEffects(ItemStack stack, LivingEntity entity) {
|
public TriState shouldTriggerUseEffects(ItemStack stack, LivingEntity entity) {
|
||||||
// Trigger every tick so that we have more fine grain control over the animation
|
// Trigger every tick so that we have more fine grain control over the animation
|
||||||
return true;
|
return TriState.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,8 +20,8 @@ import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
|
||||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||||
|
|
||||||
import net.createmod.catnip.gui.ScreenOpener;
|
|
||||||
import net.createmod.catnip.data.Iterate;
|
import net.createmod.catnip.data.Iterate;
|
||||||
|
import net.createmod.catnip.gui.ScreenOpener;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -42,6 +42,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||||
|
@ -149,13 +150,13 @@ public class SymmetryWandItem extends Item {
|
||||||
playerIn.getCooldowns()
|
playerIn.getCooldowns()
|
||||||
.addCooldown(this, 5);
|
.addCooldown(this, 5);
|
||||||
}
|
}
|
||||||
return new InteractionResultHolder<ItemStack>(InteractionResult.SUCCESS, wand);
|
return new InteractionResultHolder<>(InteractionResult.SUCCESS, wand);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No Shift -> Clear Mirror
|
// No Shift -> Clear Mirror
|
||||||
wand.getTag()
|
wand.getTag()
|
||||||
.putBoolean(ENABLE, false);
|
.putBoolean(ENABLE, false);
|
||||||
return new InteractionResultHolder<ItemStack>(InteractionResult.SUCCESS, wand);
|
return new InteractionResultHolder<>(InteractionResult.SUCCESS, wand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
|
@ -16,9 +16,9 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour
|
||||||
import com.simibubi.create.foundation.blockEntity.behaviour.animatedContainer.AnimatedContainerBehaviour;
|
import com.simibubi.create.foundation.blockEntity.behaviour.animatedContainer.AnimatedContainerBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.ResetableLazy;
|
import com.simibubi.create.foundation.utility.ResetableLazy;
|
||||||
|
|
||||||
import net.createmod.catnip.math.VecHelper;
|
|
||||||
import net.createmod.catnip.animation.LerpedFloat;
|
import net.createmod.catnip.animation.LerpedFloat;
|
||||||
import net.createmod.catnip.animation.LerpedFloat.Chaser;
|
import net.createmod.catnip.animation.LerpedFloat.Chaser;
|
||||||
|
import net.createmod.catnip.math.VecHelper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -36,6 +36,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
@ -114,7 +115,7 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
|
|
||||||
for (Iterator<Entry<Integer, WeakHashMap<Player, Integer>>> toolboxSlots = connectedPlayers.entrySet()
|
for (Iterator<Entry<Integer, WeakHashMap<Player, Integer>>> toolboxSlots = connectedPlayers.entrySet()
|
||||||
.iterator(); toolboxSlots.hasNext();) {
|
.iterator(); toolboxSlots.hasNext(); ) {
|
||||||
|
|
||||||
Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry = toolboxSlots.next();
|
Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry = toolboxSlots.next();
|
||||||
WeakHashMap<Player, Integer> set = toolboxSlotEntry.getValue();
|
WeakHashMap<Player, Integer> set = toolboxSlotEntry.getValue();
|
||||||
|
@ -124,7 +125,7 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
|
||||||
boolean clear = referenceItem.isEmpty();
|
boolean clear = referenceItem.isEmpty();
|
||||||
|
|
||||||
for (Iterator<Entry<Player, Integer>> playerEntries = set.entrySet()
|
for (Iterator<Entry<Player, Integer>> playerEntries = set.entrySet()
|
||||||
.iterator(); playerEntries.hasNext();) {
|
.iterator(); playerEntries.hasNext(); ) {
|
||||||
Entry<Player, Integer> playerEntry = playerEntries.next();
|
Entry<Player, Integer> playerEntry = playerEntries.next();
|
||||||
|
|
||||||
Player player = playerEntry.getKey();
|
Player player = playerEntry.getKey();
|
||||||
|
@ -216,16 +217,11 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
|
||||||
|
|
||||||
Set<ServerPlayer> affected = new HashSet<>();
|
Set<ServerPlayer> affected = new HashSet<>();
|
||||||
|
|
||||||
for (Iterator<Entry<Integer, WeakHashMap<Player, Integer>>> toolboxSlots = connectedPlayers.entrySet()
|
for (Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry : connectedPlayers.entrySet()) {
|
||||||
.iterator(); toolboxSlots.hasNext();) {
|
|
||||||
|
|
||||||
Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry = toolboxSlots.next();
|
|
||||||
WeakHashMap<Player, Integer> set = toolboxSlotEntry.getValue();
|
WeakHashMap<Player, Integer> set = toolboxSlotEntry.getValue();
|
||||||
|
|
||||||
for (Iterator<Entry<Player, Integer>> playerEntries = set.entrySet()
|
for (Entry<Player, Integer> playerEntry : set.entrySet()) {
|
||||||
.iterator(); playerEntries.hasNext();) {
|
|
||||||
Entry<Player, Integer> playerEntry = playerEntries.next();
|
|
||||||
|
|
||||||
Player player = playerEntry.getKey();
|
Player player = playerEntry.getKey();
|
||||||
int hotbarSlot = playerEntry.getValue();
|
int hotbarSlot = playerEntry.getValue();
|
||||||
|
|
||||||
|
@ -356,8 +352,8 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return customName != null ? customName
|
return customName != null ? customName
|
||||||
: AllBlocks.TOOLBOXES.get(getColor())
|
: AllBlocks.TOOLBOXES.get(getColor())
|
||||||
.get()
|
.get()
|
||||||
.getName();
|
.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.network.NetworkEvent.Context;
|
import net.minecraftforge.network.NetworkEvent.Context;
|
||||||
|
|
||||||
|
@ -43,9 +44,8 @@ public class ToolboxDisposeAllPacket extends SimplePacketBase {
|
||||||
if (player.distanceToSqr(toolboxPos.getX() + 0.5, toolboxPos.getY(), toolboxPos.getZ() + 0.5) > maxRange
|
if (player.distanceToSqr(toolboxPos.getX() + 0.5, toolboxPos.getY(), toolboxPos.getZ() + 0.5) > maxRange
|
||||||
* maxRange)
|
* maxRange)
|
||||||
return;
|
return;
|
||||||
if (!(blockEntity instanceof ToolboxBlockEntity))
|
if (!(blockEntity instanceof ToolboxBlockEntity toolbox))
|
||||||
return;
|
return;
|
||||||
ToolboxBlockEntity toolbox = (ToolboxBlockEntity) blockEntity;
|
|
||||||
|
|
||||||
CompoundTag compound = player.getPersistentData()
|
CompoundTag compound = player.getPersistentData()
|
||||||
.getCompound("CreateToolboxData");
|
.getCompound("CreateToolboxData");
|
||||||
|
@ -55,19 +55,19 @@ public class ToolboxDisposeAllPacket extends SimplePacketBase {
|
||||||
for (int i = 0; i < 36; i++) {
|
for (int i = 0; i < 36; i++) {
|
||||||
String key = String.valueOf(i);
|
String key = String.valueOf(i);
|
||||||
if (compound.contains(key) && NbtUtils.readBlockPos(compound.getCompound(key)
|
if (compound.contains(key) && NbtUtils.readBlockPos(compound.getCompound(key)
|
||||||
.getCompound("Pos"))
|
.getCompound("Pos"))
|
||||||
.equals(toolboxPos)) {
|
.equals(toolboxPos)) {
|
||||||
ToolboxHandler.unequip(player, i, true);
|
ToolboxHandler.unequip(player, i, true);
|
||||||
sendData.setTrue();
|
sendData.setTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack itemStack = player.getInventory().getItem(i);
|
ItemStack itemStack = player.getInventory().getItem(i);
|
||||||
ItemStack remainder = ItemHandlerHelper.insertItemStacked(toolbox.inventory, itemStack, false);
|
ItemStack remainder = ItemHandlerHelper.insertItemStacked(toolbox.inventory, itemStack, false);
|
||||||
if (remainder.getCount() != itemStack.getCount())
|
if (remainder.getCount() != itemStack.getCount())
|
||||||
player.getInventory().setItem(i, remainder);
|
player.getInventory().setItem(i, remainder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sendData.booleanValue())
|
if (sendData.booleanValue())
|
||||||
ToolboxHandler.syncData(player);
|
ToolboxHandler.syncData(player);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.network.NetworkEvent.Context;
|
import net.minecraftforge.network.NetworkEvent.Context;
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ public class ToolboxEquipPacket extends SimplePacketBase {
|
||||||
if (player.distanceToSqr(toolboxPos.getX() + 0.5, toolboxPos.getY(), toolboxPos.getZ() + 0.5) > maxRange
|
if (player.distanceToSqr(toolboxPos.getX() + 0.5, toolboxPos.getY(), toolboxPos.getZ() + 0.5) > maxRange
|
||||||
* maxRange)
|
* maxRange)
|
||||||
return;
|
return;
|
||||||
if (!(blockEntity instanceof ToolboxBlockEntity))
|
if (!(blockEntity instanceof ToolboxBlockEntity toolboxBlockEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ToolboxHandler.unequip(player, hotbarSlot, false);
|
ToolboxHandler.unequip(player, hotbarSlot, false);
|
||||||
|
@ -69,8 +70,6 @@ public class ToolboxEquipPacket extends SimplePacketBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolboxBlockEntity toolboxBlockEntity = (ToolboxBlockEntity) blockEntity;
|
|
||||||
|
|
||||||
ItemStack playerStack = player.getInventory().getItem(hotbarSlot);
|
ItemStack playerStack = player.getInventory().getItem(hotbarSlot);
|
||||||
if (!playerStack.isEmpty() && !ToolboxInventory.canItemsShareCompartment(playerStack,
|
if (!playerStack.isEmpty() && !ToolboxInventory.canItemsShareCompartment(playerStack,
|
||||||
toolboxBlockEntity.inventory.filters.get(slot))) {
|
toolboxBlockEntity.inventory.filters.get(slot))) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
public class ToolboxHandler {
|
public class ToolboxHandler {
|
||||||
|
@ -44,12 +45,11 @@ public class ToolboxHandler {
|
||||||
return;
|
return;
|
||||||
if (!(world instanceof ServerLevel))
|
if (!(world instanceof ServerLevel))
|
||||||
return;
|
return;
|
||||||
if (!(entity instanceof ServerPlayer))
|
if (!(entity instanceof ServerPlayer player))
|
||||||
return;
|
return;
|
||||||
if (entity.tickCount % validationTimer != 0)
|
if (entity.tickCount % validationTimer != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ServerPlayer player = (ServerPlayer) entity;
|
|
||||||
if (!player.getPersistentData()
|
if (!player.getPersistentData()
|
||||||
.contains("CreateToolboxData"))
|
.contains("CreateToolboxData"))
|
||||||
return;
|
return;
|
||||||
|
@ -90,8 +90,8 @@ public class ToolboxHandler {
|
||||||
if (player.getPersistentData()
|
if (player.getPersistentData()
|
||||||
.contains("CreateToolboxData")
|
.contains("CreateToolboxData")
|
||||||
&& !player.getPersistentData()
|
&& !player.getPersistentData()
|
||||||
.getCompound("CreateToolboxData")
|
.getCompound("CreateToolboxData")
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
syncData(player);
|
syncData(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,7 @@ public class ToolboxHandler {
|
||||||
int prevSlot = prevData.getInt("Slot");
|
int prevSlot = prevData.getInt("Slot");
|
||||||
|
|
||||||
BlockEntity prevBlockEntity = world.getBlockEntity(prevPos);
|
BlockEntity prevBlockEntity = world.getBlockEntity(prevPos);
|
||||||
if (prevBlockEntity instanceof ToolboxBlockEntity) {
|
if (prevBlockEntity instanceof ToolboxBlockEntity toolbox) {
|
||||||
ToolboxBlockEntity toolbox = (ToolboxBlockEntity) prevBlockEntity;
|
|
||||||
toolbox.unequip(prevSlot, player, hotbarSlot, keepItems || !ToolboxHandler.withinRange(player, toolbox));
|
toolbox.unequip(prevSlot, player, hotbarSlot, keepItems || !ToolboxHandler.withinRange(player, toolbox));
|
||||||
}
|
}
|
||||||
compound.remove(key);
|
compound.remove(key);
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
public class ToolboxMenu extends MenuBase<ToolboxBlockEntity> {
|
public class ToolboxMenu extends MenuBase<ToolboxBlockEntity> {
|
||||||
|
@ -44,8 +45,7 @@ public class ToolboxMenu extends MenuBase<ToolboxBlockEntity> {
|
||||||
|
|
||||||
ClientLevel world = Minecraft.getInstance().level;
|
ClientLevel world = Minecraft.getInstance().level;
|
||||||
BlockEntity blockEntity = world.getBlockEntity(readBlockPos);
|
BlockEntity blockEntity = world.getBlockEntity(readBlockPos);
|
||||||
if (blockEntity instanceof ToolboxBlockEntity) {
|
if (blockEntity instanceof ToolboxBlockEntity toolbox) {
|
||||||
ToolboxBlockEntity toolbox = (ToolboxBlockEntity) blockEntity;
|
|
||||||
toolbox.readClient(readNbt);
|
toolbox.readClient(readNbt);
|
||||||
return toolbox;
|
return toolbox;
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,8 @@ public class ToolboxMenu extends MenuBase<ToolboxBlockEntity> {
|
||||||
int x = 79;
|
int x = 79;
|
||||||
int y = 37;
|
int y = 37;
|
||||||
|
|
||||||
int[] xOffsets = { x, x + 33, x + 66, x + 66 + 6, x + 66, x + 33, x, x - 6 };
|
int[] xOffsets = {x, x + 33, x + 66, x + 66 + 6, x + 66, x + 33, x, x - 6};
|
||||||
int[] yOffsets = { y, y - 6, y, y + 33, y + 66, y + 66 + 6, y + 66, y + 33 };
|
int[] yOffsets = {y, y - 6, y, y + 33, y + 66, y + 66 + 6, y + 66, y + 33};
|
||||||
|
|
||||||
for (int compartment = 0; compartment < 8; compartment++) {
|
for (int compartment = 0; compartment < 8; compartment++) {
|
||||||
int baseIndex = compartment * STACKS_PER_COMPARTMENT;
|
int baseIndex = compartment * STACKS_PER_COMPARTMENT;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -40,12 +41,11 @@ public class WrenchEventHandler {
|
||||||
.getBlockState(event.getPos());
|
.getBlockState(event.getPos());
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
if (!(block instanceof IWrenchable))
|
if (!(block instanceof IWrenchable actor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockHitResult hitVec = event.getHitVec();
|
BlockHitResult hitVec = event.getHitVec();
|
||||||
UseOnContext context = new UseOnContext(player, event.getHand(), hitVec);
|
UseOnContext context = new UseOnContext(player, event.getHand(), hitVec);
|
||||||
IWrenchable actor = (IWrenchable) block;
|
|
||||||
|
|
||||||
InteractionResult result =
|
InteractionResult result =
|
||||||
player.isShiftKeyDown() ? actor.onSneakWrenched(state, context) : actor.onWrenched(state, context);
|
player.isShiftKeyDown() ? actor.onSneakWrenched(state, context) : actor.onWrenched(state, context);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||||
|
@ -44,13 +45,12 @@ public class WrenchItem extends Item {
|
||||||
.getBlockState(context.getClickedPos());
|
.getBlockState(context.getClickedPos());
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
if (!(block instanceof IWrenchable)) {
|
if (!(block instanceof IWrenchable actor)) {
|
||||||
if (player.isShiftKeyDown() && canWrenchPickup(state))
|
if (player.isShiftKeyDown() && canWrenchPickup(state))
|
||||||
return onItemUseOnOther(context);
|
return onItemUseOnOther(context);
|
||||||
return super.useOn(context);
|
return super.useOn(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
IWrenchable actor = (IWrenchable) block;
|
|
||||||
if (player.isShiftKeyDown())
|
if (player.isShiftKeyDown())
|
||||||
return actor.onSneakWrenched(state, context);
|
return actor.onSneakWrenched(state, context);
|
||||||
return actor.onWrenched(state, context);
|
return actor.onWrenched(state, context);
|
||||||
|
@ -78,7 +78,7 @@ public class WrenchItem extends Item {
|
||||||
|
|
||||||
public static void wrenchInstaKillsMinecarts(AttackEntityEvent event) {
|
public static void wrenchInstaKillsMinecarts(AttackEntityEvent event) {
|
||||||
Entity target = event.getTarget();
|
Entity target = event.getTarget();
|
||||||
if (!(target instanceof AbstractMinecart))
|
if (!(target instanceof AbstractMinecart minecart))
|
||||||
return;
|
return;
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
ItemStack heldItem = player.getMainHandItem();
|
ItemStack heldItem = player.getMainHandItem();
|
||||||
|
@ -86,7 +86,6 @@ public class WrenchItem extends Item {
|
||||||
return;
|
return;
|
||||||
if (player.isCreative())
|
if (player.isCreative())
|
||||||
return;
|
return;
|
||||||
AbstractMinecart minecart = (AbstractMinecart) target;
|
|
||||||
minecart.hurt(minecart.damageSources().playerAttack(player), 100);
|
minecart.hurt(minecart.damageSources().playerAttack(player), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
|
||||||
public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainBlockEntity> {
|
public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainBlockEntity> {
|
||||||
|
@ -42,12 +43,12 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||||
BlockHitResult hit) {
|
BlockHitResult hit) {
|
||||||
ItemStack heldItem = player.getItemInHand(handIn);
|
ItemStack heldItem = player.getItemInHand(handIn);
|
||||||
|
|
||||||
if (heldItem.getItem() instanceof BlockItem
|
if (heldItem.getItem() instanceof BlockItem
|
||||||
&& !heldItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
|
&& !heldItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
|
||||||
.isPresent())
|
.isPresent())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
||||||
return onBlockEntityUse(worldIn, pos, be -> {
|
return onBlockEntityUse(worldIn, pos, be -> {
|
||||||
|
@ -73,14 +74,13 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
|
||||||
@Override
|
@Override
|
||||||
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
|
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
|
||||||
super.updateEntityAfterFallOn(worldIn, entityIn);
|
super.updateEntityAfterFallOn(worldIn, entityIn);
|
||||||
if (!(entityIn instanceof ItemEntity))
|
if (!(entityIn instanceof ItemEntity itemEntity))
|
||||||
return;
|
return;
|
||||||
if (!entityIn.isAlive())
|
if (!entityIn.isAlive())
|
||||||
return;
|
return;
|
||||||
if (entityIn.level().isClientSide)
|
if (entityIn.level().isClientSide)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemEntity itemEntity = (ItemEntity) entityIn;
|
|
||||||
DirectBeltInputBehaviour inputBehaviour =
|
DirectBeltInputBehaviour inputBehaviour =
|
||||||
BlockEntityBehaviour.get(worldIn, entityIn.blockPosition(), DirectBeltInputBehaviour.TYPE);
|
BlockEntityBehaviour.get(worldIn, entityIn.blockPosition(), DirectBeltInputBehaviour.TYPE);
|
||||||
if (inputBehaviour == null)
|
if (inputBehaviour == null)
|
||||||
|
@ -96,7 +96,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InteractionResult tryExchange(Level worldIn, Player player, InteractionHand handIn, ItemStack heldItem,
|
protected InteractionResult tryExchange(Level worldIn, Player player, InteractionHand handIn, ItemStack heldItem,
|
||||||
ItemDrainBlockEntity be) {
|
ItemDrainBlockEntity be) {
|
||||||
if (FluidHelper.tryEmptyItemIntoBE(worldIn, player, handIn, heldItem, be))
|
if (FluidHelper.tryEmptyItemIntoBE(worldIn, player, handIn, heldItem, be))
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
if (GenericItemEmptying.canItemBeEmptied(worldIn, heldItem))
|
if (GenericItemEmptying.canItemBeEmptied(worldIn, heldItem))
|
||||||
|
@ -106,7 +106,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
||||||
CollisionContext p_220053_4_) {
|
CollisionContext p_220053_4_) {
|
||||||
return AllShapes.CASING_13PX.get(Direction.UP);
|
return AllShapes.CASING_13PX.get(Direction.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.core.particles.ParticleOptions;
|
||||||
import net.minecraft.core.particles.ParticleType;
|
import net.minecraft.core.particles.ParticleType;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.level.material.Fluids;
|
import net.minecraft.world.level.material.Fluids;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
@ -22,7 +23,8 @@ public class FluidParticleData implements ParticleOptions, ICustomParticleData<F
|
||||||
private ParticleType<FluidParticleData> type;
|
private ParticleType<FluidParticleData> type;
|
||||||
private FluidStack fluid;
|
private FluidStack fluid;
|
||||||
|
|
||||||
public FluidParticleData() {}
|
public FluidParticleData() {
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public FluidParticleData(ParticleType<?> type, FluidStack fluid) {
|
public FluidParticleData(ParticleType<?> type, FluidStack fluid) {
|
||||||
|
@ -68,7 +70,7 @@ public class FluidParticleData implements ParticleOptions, ICustomParticleData<F
|
||||||
.apply(i, fs -> new FluidParticleData(AllParticleTypes.FLUID_DRIP.get(), fs)));
|
.apply(i, fs -> new FluidParticleData(AllParticleTypes.FLUID_DRIP.get(), fs)));
|
||||||
|
|
||||||
public static final ParticleOptions.Deserializer<FluidParticleData> DESERIALIZER =
|
public static final ParticleOptions.Deserializer<FluidParticleData> DESERIALIZER =
|
||||||
new ParticleOptions.Deserializer<FluidParticleData>() {
|
new ParticleOptions.Deserializer<>() {
|
||||||
|
|
||||||
// TODO Fluid particles on command
|
// TODO Fluid particles on command
|
||||||
public FluidParticleData fromCommand(ParticleType<FluidParticleData> particleTypeIn, StringReader reader)
|
public FluidParticleData fromCommand(ParticleType<FluidParticleData> particleTypeIn, StringReader reader)
|
||||||
|
|
|
@ -58,13 +58,13 @@ public class PumpBlock extends DirectionalKineticBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
||||||
CollisionContext p_220053_4_) {
|
CollisionContext p_220053_4_) {
|
||||||
return AllShapes.PUMP.get(state.getValue(FACING));
|
return AllShapes.PUMP.get(state.getValue(FACING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos,
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos,
|
||||||
boolean isMoving) {
|
boolean isMoving) {
|
||||||
DebugPackets.sendNeighborsUpdatePacket(world, pos);
|
DebugPackets.sendNeighborsUpdatePacket(world, pos);
|
||||||
Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving);
|
Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving);
|
||||||
if (d == null)
|
if (d == null)
|
||||||
|
@ -88,7 +88,7 @@ public class PumpBlock extends DirectionalKineticBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world,
|
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world,
|
||||||
BlockPos pos, BlockPos neighbourPos) {
|
BlockPos pos, BlockPos neighbourPos) {
|
||||||
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
||||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||||
return state;
|
return state;
|
||||||
|
@ -146,9 +146,8 @@ public class PumpBlock extends DirectionalKineticBlock
|
||||||
if (isPump(state) && isPump(oldState) && state.getValue(FACING) == oldState.getValue(FACING)
|
if (isPump(state) && isPump(oldState) && state.getValue(FACING) == oldState.getValue(FACING)
|
||||||
.getOpposite()) {
|
.getOpposite()) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (!(blockEntity instanceof PumpBlockEntity))
|
if (!(blockEntity instanceof PumpBlockEntity pump))
|
||||||
return;
|
return;
|
||||||
PumpBlockEntity pump = (PumpBlockEntity) blockEntity;
|
|
||||||
pump.pressureUpdate = true;
|
pump.pressureUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||||
|
|
||||||
import net.createmod.catnip.math.BlockFace;
|
|
||||||
import net.createmod.catnip.data.Couple;
|
import net.createmod.catnip.data.Couple;
|
||||||
import net.createmod.catnip.data.Iterate;
|
import net.createmod.catnip.data.Iterate;
|
||||||
import net.createmod.catnip.data.Pair;
|
import net.createmod.catnip.data.Pair;
|
||||||
|
import net.createmod.catnip.math.BlockFace;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -33,6 +33,7 @@ import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
|
@ -226,7 +227,7 @@ public class PumpBlockEntity extends KineticBlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean searchForEndpointRecursively(Map<BlockPos, Pair<Integer, Map<Direction, Boolean>>> pipeGraph,
|
protected boolean searchForEndpointRecursively(Map<BlockPos, Pair<Integer, Map<Direction, Boolean>>> pipeGraph,
|
||||||
Set<BlockFace> targets, Map<Integer, Set<BlockFace>> validFaces, BlockFace currentFace, boolean pull) {
|
Set<BlockFace> targets, Map<Integer, Set<BlockFace>> validFaces, BlockFace currentFace, boolean pull) {
|
||||||
BlockPos currentPos = currentFace.getPos();
|
BlockPos currentPos = currentFace.getPos();
|
||||||
if (!pipeGraph.containsKey(currentPos))
|
if (!pipeGraph.containsKey(currentPos))
|
||||||
return false;
|
return false;
|
||||||
|
@ -275,8 +276,7 @@ public class PumpBlockEntity extends KineticBlockEntity {
|
||||||
|
|
||||||
// facing a pump
|
// facing a pump
|
||||||
if (PumpBlock.isPump(connectedState) && connectedState.getValue(PumpBlock.FACING)
|
if (PumpBlock.isPump(connectedState) && connectedState.getValue(PumpBlock.FACING)
|
||||||
.getAxis() == face.getAxis() && blockEntity instanceof PumpBlockEntity) {
|
.getAxis() == face.getAxis() && blockEntity instanceof PumpBlockEntity pumpBE) {
|
||||||
PumpBlockEntity pumpBE = (PumpBlockEntity) blockEntity;
|
|
||||||
return pumpBE.isPullingOnSide(pumpBE.isFront(blockFace.getOppositeFace())) != pull;
|
return pumpBE.isPullingOnSide(pumpBE.isFront(blockFace.getOppositeFace())) != pull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ public class PumpBlockEntity extends KineticBlockEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state,
|
public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state,
|
||||||
Direction direction) {
|
Direction direction) {
|
||||||
AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction);
|
AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction);
|
||||||
if (attachment == AttachmentTypes.RIM)
|
if (attachment == AttachmentTypes.RIM)
|
||||||
return AttachmentTypes.NONE;
|
return AttachmentTypes.NONE;
|
||||||
|
|
|
@ -114,6 +114,7 @@ public class SpoutBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
|
||||||
// Process finished
|
// Process finished
|
||||||
ItemStack out = FillingBySpout.fillItem(level, requiredAmountForItem, transported.stack, fluid);
|
ItemStack out = FillingBySpout.fillItem(level, requiredAmountForItem, transported.stack, fluid);
|
||||||
if (!out.isEmpty()) {
|
if (!out.isEmpty()) {
|
||||||
|
transported.clearFanProcessingData();
|
||||||
List<TransportedItemStack> outList = new ArrayList<>();
|
List<TransportedItemStack> outList = new ArrayList<>();
|
||||||
TransportedItemStack held = null;
|
TransportedItemStack held = null;
|
||||||
TransportedItemStack result = transported.copy();
|
TransportedItemStack result = transported.copy();
|
||||||
|
|
|
@ -49,6 +49,7 @@ import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.ForgeSoundType;
|
import net.minecraftforge.common.util.ForgeSoundType;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
@ -124,7 +125,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
|
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
|
||||||
CollisionContext pContext) {
|
CollisionContext pContext) {
|
||||||
if (pContext == CollisionContext.empty())
|
if (pContext == CollisionContext.empty())
|
||||||
return CAMPFIRE_SMOKE_CLIP;
|
return CAMPFIRE_SMOKE_CLIP;
|
||||||
return pState.getShape(pLevel, pPos);
|
return pState.getShape(pLevel, pPos);
|
||||||
|
@ -137,7 +138,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState,
|
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState,
|
||||||
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
|
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
|
||||||
if (pDirection == Direction.DOWN && pNeighborState.getBlock() != this)
|
if (pDirection == Direction.DOWN && pNeighborState.getBlock() != this)
|
||||||
withBlockEntityDo(pLevel, pCurrentPos, FluidTankBlockEntity::updateBoilerTemperature);
|
withBlockEntityDo(pLevel, pCurrentPos, FluidTankBlockEntity::updateBoilerTemperature);
|
||||||
return pState;
|
return pState;
|
||||||
|
@ -145,7 +146,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||||
BlockHitResult ray) {
|
BlockHitResult ray) {
|
||||||
ItemStack heldItem = player.getItemInHand(hand);
|
ItemStack heldItem = player.getItemInHand(hand);
|
||||||
boolean onClient = world.isClientSide;
|
boolean onClient = world.isClientSide;
|
||||||
|
|
||||||
|
@ -256,9 +257,8 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (state.hasBlockEntity() && (state.getBlock() != newState.getBlock() || !newState.hasBlockEntity())) {
|
if (state.hasBlockEntity() && (state.getBlock() != newState.getBlock() || !newState.hasBlockEntity())) {
|
||||||
BlockEntity be = world.getBlockEntity(pos);
|
BlockEntity be = world.getBlockEntity(pos);
|
||||||
if (!(be instanceof FluidTankBlockEntity))
|
if (!(be instanceof FluidTankBlockEntity tankBE))
|
||||||
return;
|
return;
|
||||||
FluidTankBlockEntity tankBE = (FluidTankBlockEntity) be;
|
|
||||||
world.removeBlockEntity(pos);
|
world.removeBlockEntity(pos);
|
||||||
ConnectivityHandler.splitMulti(tankBE);
|
ConnectivityHandler.splitMulti(tankBE);
|
||||||
}
|
}
|
||||||
|
@ -280,16 +280,16 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
return state;
|
return state;
|
||||||
boolean x = mirror == Mirror.FRONT_BACK;
|
boolean x = mirror == Mirror.FRONT_BACK;
|
||||||
switch (state.getValue(SHAPE)) {
|
switch (state.getValue(SHAPE)) {
|
||||||
case WINDOW_NE:
|
case WINDOW_NE:
|
||||||
return state.setValue(SHAPE, x ? Shape.WINDOW_NW : Shape.WINDOW_SE);
|
return state.setValue(SHAPE, x ? Shape.WINDOW_NW : Shape.WINDOW_SE);
|
||||||
case WINDOW_NW:
|
case WINDOW_NW:
|
||||||
return state.setValue(SHAPE, x ? Shape.WINDOW_NE : Shape.WINDOW_SW);
|
return state.setValue(SHAPE, x ? Shape.WINDOW_NE : Shape.WINDOW_SW);
|
||||||
case WINDOW_SE:
|
case WINDOW_SE:
|
||||||
return state.setValue(SHAPE, x ? Shape.WINDOW_SW : Shape.WINDOW_NE);
|
return state.setValue(SHAPE, x ? Shape.WINDOW_SW : Shape.WINDOW_NE);
|
||||||
case WINDOW_SW:
|
case WINDOW_SW:
|
||||||
return state.setValue(SHAPE, x ? Shape.WINDOW_SE : Shape.WINDOW_NW);
|
return state.setValue(SHAPE, x ? Shape.WINDOW_SE : Shape.WINDOW_NW);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,16 +302,16 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
|
|
||||||
private BlockState rotateOnce(BlockState state) {
|
private BlockState rotateOnce(BlockState state) {
|
||||||
switch (state.getValue(SHAPE)) {
|
switch (state.getValue(SHAPE)) {
|
||||||
case WINDOW_NE:
|
case WINDOW_NE:
|
||||||
return state.setValue(SHAPE, Shape.WINDOW_SE);
|
return state.setValue(SHAPE, Shape.WINDOW_SE);
|
||||||
case WINDOW_NW:
|
case WINDOW_NW:
|
||||||
return state.setValue(SHAPE, Shape.WINDOW_NE);
|
return state.setValue(SHAPE, Shape.WINDOW_NE);
|
||||||
case WINDOW_SE:
|
case WINDOW_SE:
|
||||||
return state.setValue(SHAPE, Shape.WINDOW_SW);
|
return state.setValue(SHAPE, Shape.WINDOW_SW);
|
||||||
case WINDOW_SW:
|
case WINDOW_SW:
|
||||||
return state.setValue(SHAPE, Shape.WINDOW_NW);
|
return state.setValue(SHAPE, Shape.WINDOW_NW);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
|
||||||
|
|
||||||
public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) {
|
public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) {
|
||||||
BlockState tankState = pLevel.getBlockState(tankPos);
|
BlockState tankState = pLevel.getBlockState(tankPos);
|
||||||
if (!(tankState.getBlock()instanceof FluidTankBlock tank))
|
if (!(tankState.getBlock() instanceof FluidTankBlock tank))
|
||||||
return;
|
return;
|
||||||
FluidTankBlockEntity tankBE = tank.getBlockEntity(pLevel, tankPos);
|
FluidTankBlockEntity tankBE = tank.getBlockEntity(pLevel, tankPos);
|
||||||
if (tankBE == null)
|
if (tankBE == null)
|
||||||
|
|
|
@ -15,8 +15,8 @@ import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.PriorityQueue;
|
import it.unimi.dsi.fastutil.PriorityQueue;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
|
import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
|
||||||
import net.createmod.catnip.math.BBHelper;
|
|
||||||
import net.createmod.catnip.data.Iterate;
|
import net.createmod.catnip.data.Iterate;
|
||||||
|
import net.createmod.catnip.math.BBHelper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -29,6 +29,7 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||||
import net.minecraft.world.level.material.Fluid;
|
import net.minecraft.world.level.material.Fluid;
|
||||||
import net.minecraft.world.level.material.Fluids;
|
import net.minecraft.world.level.material.Fluids;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
|
public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
|
||||||
|
@ -106,8 +107,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
|
||||||
&& blockState.getValue(BlockStateProperties.WATERLOGGED)) {
|
&& blockState.getValue(BlockStateProperties.WATERLOGGED)) {
|
||||||
emptied = blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false));
|
emptied = blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false));
|
||||||
fluid = Fluids.WATER;
|
fluid = Fluids.WATER;
|
||||||
} else if (blockState.getBlock() instanceof LiquidBlock) {
|
} else if (blockState.getBlock() instanceof LiquidBlock flowingFluid) {
|
||||||
LiquidBlock flowingFluid = (LiquidBlock) blockState.getBlock();
|
|
||||||
emptied = Blocks.AIR.defaultBlockState();
|
emptied = Blocks.AIR.defaultBlockState();
|
||||||
if (blockState.getValue(LiquidBlock.LEVEL) == 0)
|
if (blockState.getValue(LiquidBlock.LEVEL) == 0)
|
||||||
fluid = flowingFluid.getFluid();
|
fluid = flowingFluid.getFluid();
|
||||||
|
@ -124,7 +124,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
|
||||||
}
|
}
|
||||||
} else if (blockState.getFluidState()
|
} else if (blockState.getFluidState()
|
||||||
.getType() != Fluids.EMPTY && blockState.getCollisionShape(world, currentPos, CollisionContext.empty())
|
.getType() != Fluids.EMPTY && blockState.getCollisionShape(world, currentPos, CollisionContext.empty())
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
fluid = blockState.getFluidState()
|
fluid = blockState.getFluidState()
|
||||||
.getType();
|
.getType();
|
||||||
emptied = Blocks.AIR.defaultBlockState();
|
emptied = Blocks.AIR.defaultBlockState();
|
||||||
|
@ -229,7 +229,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
|
||||||
return blockState.getValue(LiquidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING;
|
return blockState.getValue(LiquidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING;
|
||||||
if (blockState.getFluidState()
|
if (blockState.getFluidState()
|
||||||
.getType() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty())
|
.getType() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty())
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
return FluidBlockType.SOURCE;
|
return FluidBlockType.SOURCE;
|
||||||
return FluidBlockType.NONE;
|
return FluidBlockType.NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.PriorityQueue;
|
import it.unimi.dsi.fastutil.PriorityQueue;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
|
import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
|
||||||
import net.createmod.catnip.math.BBHelper;
|
|
||||||
import net.createmod.catnip.data.Iterate;
|
import net.createmod.catnip.data.Iterate;
|
||||||
|
import net.createmod.catnip.math.BBHelper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
@ -203,8 +203,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelTickAccess<Fluid> pendingFluidTicks = world.getFluidTicks();
|
LevelTickAccess<Fluid> pendingFluidTicks = world.getFluidTicks();
|
||||||
if (pendingFluidTicks instanceof LevelTicks) {
|
if (pendingFluidTicks instanceof LevelTicks<Fluid> serverTickList) {
|
||||||
LevelTicks<Fluid> serverTickList = (LevelTicks<Fluid>) pendingFluidTicks;
|
|
||||||
serverTickList.clearArea(new BoundingBox(currentPos));
|
serverTickList.clearArea(new BoundingBox(currentPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +267,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
|
||||||
|
|
||||||
if (fluidState.getType() != Fluids.EMPTY
|
if (fluidState.getType() != Fluids.EMPTY
|
||||||
&& blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty())
|
&& blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty())
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
return toFill.isSame(fluidState.getType()) ? SpaceType.FILLED : SpaceType.BLOCKING;
|
return toFill.isSame(fluidState.getType()) ? SpaceType.FILLED : SpaceType.BLOCKING;
|
||||||
|
|
||||||
return canBeReplacedByFluid(world, pos, blockState) ? SpaceType.FILLABLE : SpaceType.BLOCKING;
|
return canBeReplacedByFluid(world, pos, blockState) ? SpaceType.FILLABLE : SpaceType.BLOCKING;
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
|
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
|
||||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||||
|
|
||||||
import net.createmod.catnip.render.SuperByteBufferCache;
|
|
||||||
import net.createmod.catnip.math.VecHelper;
|
import net.createmod.catnip.math.VecHelper;
|
||||||
import net.createmod.catnip.outliner.Outliner;
|
import net.createmod.catnip.outliner.Outliner;
|
||||||
|
import net.createmod.catnip.render.SuperByteBufferCache;
|
||||||
import net.createmod.catnip.theme.Color;
|
import net.createmod.catnip.theme.Color;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
@ -47,16 +47,16 @@ public class KineticDebugger {
|
||||||
if (be.getTheoreticalSpeed() != 0 && !shape.isEmpty())
|
if (be.getTheoreticalSpeed() != 0 && !shape.isEmpty())
|
||||||
Outliner.getInstance().chaseAABB("kineticSource", shape.bounds()
|
Outliner.getInstance().chaseAABB("kineticSource", shape.bounds()
|
||||||
.move(toOutline))
|
.move(toOutline))
|
||||||
.lineWidth(1 / 16f)
|
.lineWidth(1 / 16f)
|
||||||
.colored(be.hasSource() ? Color.generateFromLong(be.network).getRGB() : 0xffcc00);
|
.colored(be.hasSource() ? Color.generateFromLong(be.network).getRGB() : 0xffcc00);
|
||||||
|
|
||||||
if (state.getBlock() instanceof IRotate) {
|
if (state.getBlock() instanceof IRotate) {
|
||||||
Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
|
Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
|
||||||
Vec3 vec = Vec3.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis)
|
Vec3 vec = Vec3.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis)
|
||||||
.getNormal());
|
.getNormal());
|
||||||
Vec3 center = VecHelper.getCenterOf(be.getBlockPos());
|
Vec3 center = VecHelper.getCenterOf(be.getBlockPos());
|
||||||
Outliner.getInstance().showLine("rotationAxis", center.add(vec), center.subtract(vec))
|
Outliner.getInstance().showLine("rotationAxis", center.add(vec), center.subtract(vec))
|
||||||
.lineWidth(1 / 16f);
|
.lineWidth(1 / 16f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,9 @@ public class KineticDebugger {
|
||||||
return null;
|
return null;
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return null;
|
return null;
|
||||||
if (!(obj instanceof BlockHitResult))
|
if (!(obj instanceof BlockHitResult ray))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BlockHitResult ray = (BlockHitResult) obj;
|
|
||||||
BlockEntity be = world.getBlockEntity(ray.getBlockPos());
|
BlockEntity be = world.getBlockEntity(ray.getBlockPos());
|
||||||
if (!(be instanceof KineticBlockEntity))
|
if (!(be instanceof KineticBlockEntity))
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -47,11 +47,9 @@ public class RotationPropagator {
|
||||||
|
|
||||||
Block fromBlock = stateFrom.getBlock();
|
Block fromBlock = stateFrom.getBlock();
|
||||||
Block toBlock = stateTo.getBlock();
|
Block toBlock = stateTo.getBlock();
|
||||||
if (!(fromBlock instanceof IRotate && toBlock instanceof IRotate))
|
if (!(fromBlock instanceof IRotate definitionFrom && toBlock instanceof IRotate definitionTo))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
final IRotate definitionFrom = (IRotate) fromBlock;
|
|
||||||
final IRotate definitionTo = (IRotate) toBlock;
|
|
||||||
final BlockPos diff = to.getBlockPos()
|
final BlockPos diff = to.getBlockPos()
|
||||||
.subtract(from.getBlockPos());
|
.subtract(from.getBlockPos());
|
||||||
final Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ());
|
final Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ());
|
||||||
|
@ -157,7 +155,7 @@ public class RotationPropagator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getAxisModifier(KineticBlockEntity be, Direction direction) {
|
private static float getAxisModifier(KineticBlockEntity be, Direction direction) {
|
||||||
if (!(be.hasSource()||be.isSource()) || !(be instanceof DirectionalShaftHalvesBlockEntity))
|
if (!(be.hasSource() || be.isSource()) || !(be instanceof DirectionalShaftHalvesBlockEntity))
|
||||||
return 1;
|
return 1;
|
||||||
Direction source = ((DirectionalShaftHalvesBlockEntity) be).getSourceFacing();
|
Direction source = ((DirectionalShaftHalvesBlockEntity) be).getSourceFacing();
|
||||||
|
|
||||||
|
@ -235,7 +233,7 @@ public class RotationPropagator {
|
||||||
Math.signum(newSpeed) != Math.signum(speedOfNeighbour) && (newSpeed != 0 && speedOfNeighbour != 0);
|
Math.signum(newSpeed) != Math.signum(speedOfNeighbour) && (newSpeed != 0 && speedOfNeighbour != 0);
|
||||||
|
|
||||||
boolean tooFast = Math.abs(newSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get()
|
boolean tooFast = Math.abs(newSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get()
|
||||||
|| Math.abs(oppositeSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get();
|
|| Math.abs(oppositeSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get();
|
||||||
// Check for both the new speed and the opposite speed, just in case
|
// Check for both the new speed and the opposite speed, just in case
|
||||||
|
|
||||||
boolean speedChangedTooOften = currentTE.getFlickerScore() > MAX_FLICKER_SCORE;
|
boolean speedChangedTooOften = currentTE.getFlickerScore() > MAX_FLICKER_SCORE;
|
||||||
|
@ -321,10 +319,9 @@ public class RotationPropagator {
|
||||||
if (!(neighbourState.getBlock() instanceof IRotate))
|
if (!(neighbourState.getBlock() instanceof IRotate))
|
||||||
continue;
|
continue;
|
||||||
BlockEntity blockEntity = worldIn.getBlockEntity(neighbourPos);
|
BlockEntity blockEntity = worldIn.getBlockEntity(neighbourPos);
|
||||||
if (!(blockEntity instanceof KineticBlockEntity))
|
if (!(blockEntity instanceof KineticBlockEntity neighbourBE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
final KineticBlockEntity neighbourBE = (KineticBlockEntity) blockEntity;
|
|
||||||
if (!neighbourBE.hasSource() || !neighbourBE.source.equals(pos))
|
if (!neighbourBE.hasSource() || !neighbourBE.source.equals(pos))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -350,9 +347,8 @@ public class RotationPropagator {
|
||||||
while (!frontier.isEmpty()) {
|
while (!frontier.isEmpty()) {
|
||||||
final BlockPos pos = frontier.remove(0);
|
final BlockPos pos = frontier.remove(0);
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (!(blockEntity instanceof KineticBlockEntity))
|
if (!(blockEntity instanceof KineticBlockEntity currentBE))
|
||||||
continue;
|
continue;
|
||||||
final KineticBlockEntity currentBE = (KineticBlockEntity) blockEntity;
|
|
||||||
|
|
||||||
currentBE.removeSource();
|
currentBE.removeSource();
|
||||||
currentBE.sendData();
|
currentBE.sendData();
|
||||||
|
@ -393,9 +389,8 @@ public class RotationPropagator {
|
||||||
return null;
|
return null;
|
||||||
BlockEntity neighbourBE = currentTE.getLevel()
|
BlockEntity neighbourBE = currentTE.getLevel()
|
||||||
.getBlockEntity(neighbourPos);
|
.getBlockEntity(neighbourPos);
|
||||||
if (!(neighbourBE instanceof KineticBlockEntity))
|
if (!(neighbourBE instanceof KineticBlockEntity neighbourKBE))
|
||||||
return null;
|
return null;
|
||||||
KineticBlockEntity neighbourKBE = (KineticBlockEntity) neighbourBE;
|
|
||||||
if (!(neighbourKBE.getBlockState()
|
if (!(neighbourKBE.getBlockState()
|
||||||
.getBlock() instanceof IRotate))
|
.getBlock() instanceof IRotate))
|
||||||
return null;
|
return null;
|
||||||
|
@ -439,9 +434,8 @@ public class RotationPropagator {
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = be.getBlockState();
|
BlockState blockState = be.getBlockState();
|
||||||
if (!(blockState.getBlock() instanceof IRotate))
|
if (!(blockState.getBlock() instanceof IRotate block))
|
||||||
return neighbours;
|
return neighbours;
|
||||||
IRotate block = (IRotate) blockState.getBlock();
|
|
||||||
return be.addPropagationLocations(block, blockState, neighbours);
|
return be.addPropagationLocations(block, blockState, neighbours);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,8 @@ public abstract class GeneratingKineticBlockEntity extends KineticBlockEntity {
|
||||||
public void setSource(BlockPos source) {
|
public void setSource(BlockPos source) {
|
||||||
super.setSource(source);
|
super.setSource(source);
|
||||||
BlockEntity blockEntity = level.getBlockEntity(source);
|
BlockEntity blockEntity = level.getBlockEntity(source);
|
||||||
if (!(blockEntity instanceof KineticBlockEntity))
|
if (!(blockEntity instanceof KineticBlockEntity sourceBE))
|
||||||
return;
|
return;
|
||||||
KineticBlockEntity sourceBE = (KineticBlockEntity) blockEntity;
|
|
||||||
if (reActivateSource && Math.abs(sourceBE.getSpeed()) >= Math.abs(getGeneratedSpeed()))
|
if (reActivateSource && Math.abs(sourceBE.getSpeed()) >= Math.abs(getGeneratedSpeed()))
|
||||||
reActivateSource = false;
|
reActivateSource = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
// we can prevent a major re-propagation here
|
// we can prevent a major re-propagation here
|
||||||
|
|
||||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||||
if (blockEntity instanceof KineticBlockEntity) {
|
if (blockEntity instanceof KineticBlockEntity kineticBlockEntity) {
|
||||||
KineticBlockEntity kineticBlockEntity = (KineticBlockEntity) blockEntity;
|
|
||||||
kineticBlockEntity.preventSpeedUpdate = 0;
|
kineticBlockEntity.preventSpeedUpdate = 0;
|
||||||
|
|
||||||
if (oldState.getBlock() != state.getBlock())
|
if (oldState.getBlock() != state.getBlock())
|
||||||
|
@ -42,7 +41,7 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
kineticBlockEntity.preventSpeedUpdate = 2;
|
kineticBlockEntity.preventSpeedUpdate = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
|
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
|
||||||
IBE.onRemove(pState, pLevel, pPos, pNewState);
|
IBE.onRemove(pState, pLevel, pPos, pNewState);
|
||||||
|
@ -61,14 +60,13 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateIndirectNeighbourShapes(BlockState stateIn, LevelAccessor worldIn, BlockPos pos, int flags,
|
public void updateIndirectNeighbourShapes(BlockState stateIn, LevelAccessor worldIn, BlockPos pos, int flags,
|
||||||
int count) {
|
int count) {
|
||||||
if (worldIn.isClientSide())
|
if (worldIn.isClientSide())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||||
if (!(blockEntity instanceof KineticBlockEntity))
|
if (!(blockEntity instanceof KineticBlockEntity kbe))
|
||||||
return;
|
return;
|
||||||
KineticBlockEntity kbe = (KineticBlockEntity) blockEntity;
|
|
||||||
|
|
||||||
if (kbe.preventSpeedUpdate > 0)
|
if (kbe.preventSpeedUpdate > 0)
|
||||||
return;
|
return;
|
||||||
|
@ -86,10 +84,9 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||||
if (!(blockEntity instanceof KineticBlockEntity))
|
if (!(blockEntity instanceof KineticBlockEntity kbe))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
KineticBlockEntity kbe = (KineticBlockEntity) blockEntity;
|
|
||||||
kbe.effects.queueRotationIndicators();
|
kbe.effects.queueRotationIndicators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,9 +415,9 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
|
||||||
.forGoggles(tooltip);
|
.forGoggles(tooltip);
|
||||||
Component hint = CreateLang.translateDirect("gui.contraptions.network_overstressed");
|
Component hint = CreateLang.translateDirect("gui.contraptions.network_overstressed");
|
||||||
List<Component> cutString = TooltipHelper.cutTextComponent(hint, Palette.GRAY_AND_WHITE);
|
List<Component> cutString = TooltipHelper.cutTextComponent(hint, Palette.GRAY_AND_WHITE);
|
||||||
for (int i = 0; i < cutString.size(); i++)
|
for (Component component : cutString)
|
||||||
CreateLang.builder()
|
CreateLang.builder()
|
||||||
.add(cutString.get(i)
|
.add(component
|
||||||
.copy())
|
.copy())
|
||||||
.forGoggles(tooltip);
|
.forGoggles(tooltip);
|
||||||
return true;
|
return true;
|
||||||
|
@ -431,9 +431,9 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
|
||||||
CreateLang.translateDirect("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
|
CreateLang.translateDirect("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
|
||||||
.getDescriptionId()));
|
.getDescriptionId()));
|
||||||
List<Component> cutString = TooltipHelper.cutTextComponent(hint, Palette.GRAY_AND_WHITE);
|
List<Component> cutString = TooltipHelper.cutTextComponent(hint, Palette.GRAY_AND_WHITE);
|
||||||
for (int i = 0; i < cutString.size(); i++)
|
for (Component component : cutString)
|
||||||
CreateLang.builder()
|
CreateLang.builder()
|
||||||
.add(cutString.get(i)
|
.add(component
|
||||||
.copy())
|
.copy())
|
||||||
.forGoggles(tooltip);
|
.forGoggles(tooltip);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -76,10 +76,9 @@ public class KineticEffectHandler {
|
||||||
|
|
||||||
BlockState state = kte.getBlockState();
|
BlockState state = kte.getBlockState();
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!(block instanceof KineticBlock))
|
if (!(block instanceof KineticBlock kb))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
KineticBlock kb = (KineticBlock) block;
|
|
||||||
float radius1 = kb.getParticleInitialRadius();
|
float radius1 = kb.getParticleInitialRadius();
|
||||||
float radius2 = kb.getParticleTargetRadius();
|
float radius2 = kb.getParticleTargetRadius();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
import net.minecraft.core.particles.ParticleOptions;
|
||||||
import net.minecraft.core.particles.ParticleType;
|
import net.minecraft.core.particles.ParticleType;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ public class RotationIndicatorParticleData
|
||||||
implements ParticleOptions, ICustomParticleDataWithSprite<RotationIndicatorParticleData> {
|
implements ParticleOptions, ICustomParticleDataWithSprite<RotationIndicatorParticleData> {
|
||||||
|
|
||||||
// TODO 1.16 make this unnecessary
|
// TODO 1.16 make this unnecessary
|
||||||
public static final PrimitiveCodec<Character> CHAR = new PrimitiveCodec<Character>() {
|
public static final PrimitiveCodec<Character> CHAR = new PrimitiveCodec<>() {
|
||||||
@Override
|
@Override
|
||||||
public <T> DataResult<Character> read(final DynamicOps<T> ops, final T input) {
|
public <T> DataResult<Character> read(final DynamicOps<T> ops, final T input) {
|
||||||
return ops.getNumberValue(input)
|
return ops.getNumberValue(input)
|
||||||
|
@ -44,7 +45,7 @@ public class RotationIndicatorParticleData
|
||||||
|
|
||||||
public static final Codec<RotationIndicatorParticleData> CODEC = RecordCodecBuilder.create(i -> i
|
public static final Codec<RotationIndicatorParticleData> CODEC = RecordCodecBuilder.create(i -> i
|
||||||
.group(Codec.INT.fieldOf("color")
|
.group(Codec.INT.fieldOf("color")
|
||||||
.forGetter(p -> p.color),
|
.forGetter(p -> p.color),
|
||||||
Codec.FLOAT.fieldOf("speed")
|
Codec.FLOAT.fieldOf("speed")
|
||||||
.forGetter(p -> p.speed),
|
.forGetter(p -> p.speed),
|
||||||
Codec.FLOAT.fieldOf("radius1")
|
Codec.FLOAT.fieldOf("radius1")
|
||||||
|
@ -58,9 +59,9 @@ public class RotationIndicatorParticleData
|
||||||
.apply(i, RotationIndicatorParticleData::new));
|
.apply(i, RotationIndicatorParticleData::new));
|
||||||
|
|
||||||
public static final ParticleOptions.Deserializer<RotationIndicatorParticleData> DESERIALIZER =
|
public static final ParticleOptions.Deserializer<RotationIndicatorParticleData> DESERIALIZER =
|
||||||
new ParticleOptions.Deserializer<RotationIndicatorParticleData>() {
|
new ParticleOptions.Deserializer<>() {
|
||||||
public RotationIndicatorParticleData fromCommand(ParticleType<RotationIndicatorParticleData> particleTypeIn,
|
public RotationIndicatorParticleData fromCommand(ParticleType<RotationIndicatorParticleData> particleTypeIn,
|
||||||
StringReader reader) throws CommandSyntaxException {
|
StringReader reader) throws CommandSyntaxException {
|
||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
int color = reader.readInt();
|
int color = reader.readInt();
|
||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
|
@ -77,7 +78,7 @@ public class RotationIndicatorParticleData
|
||||||
}
|
}
|
||||||
|
|
||||||
public RotationIndicatorParticleData fromNetwork(ParticleType<RotationIndicatorParticleData> particleTypeIn,
|
public RotationIndicatorParticleData fromNetwork(ParticleType<RotationIndicatorParticleData> particleTypeIn,
|
||||||
FriendlyByteBuf buffer) {
|
FriendlyByteBuf buffer) {
|
||||||
return new RotationIndicatorParticleData(buffer.readInt(), buffer.readFloat(), buffer.readFloat(),
|
return new RotationIndicatorParticleData(buffer.readInt(), buffer.readFloat(), buffer.readFloat(),
|
||||||
buffer.readFloat(), buffer.readInt(), buffer.readChar());
|
buffer.readFloat(), buffer.readInt(), buffer.readChar());
|
||||||
}
|
}
|
||||||
|
@ -91,7 +92,7 @@ public class RotationIndicatorParticleData
|
||||||
final char axis;
|
final char axis;
|
||||||
|
|
||||||
public RotationIndicatorParticleData(int color, float speed, float radius1, float radius2, int lifeSpan,
|
public RotationIndicatorParticleData(int color, float speed, float radius1, float radius2, int lifeSpan,
|
||||||
char axis) {
|
char axis) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
this.radius1 = radius1;
|
this.radius1 = radius1;
|
||||||
|
@ -145,4 +146,4 @@ public class RotationIndicatorParticleData
|
||||||
return RotationIndicatorParticle.Factory::new;
|
return RotationIndicatorParticle.Factory::new;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||||
Player player) {
|
Player player) {
|
||||||
return AllItems.BELT_CONNECTOR.asStack();
|
return AllItems.BELT_CONNECTOR.asStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +191,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) {
|
public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) {
|
||||||
if (!canTransportObjects(state))
|
if (!canTransportObjects(state))
|
||||||
return;
|
return;
|
||||||
if (entityIn instanceof Player) {
|
if (entityIn instanceof Player player) {
|
||||||
Player player = (Player) entityIn;
|
|
||||||
if (player.isShiftKeyDown() && !AllItems.CARDBOARD_BOOTS.isIn(player.getItemBySlot(EquipmentSlot.FEET)))
|
if (player.isShiftKeyDown() && !AllItems.CARDBOARD_BOOTS.isIn(player.getItemBySlot(EquipmentSlot.FEET)))
|
||||||
return;
|
return;
|
||||||
if (player.getAbilities().flying)
|
if (player.getAbilities().flying)
|
||||||
|
@ -253,7 +252,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn,
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn,
|
||||||
BlockHitResult hit) {
|
BlockHitResult hit) {
|
||||||
if (player.isShiftKeyDown() || !player.mayBuild())
|
if (player.isShiftKeyDown() || !player.mayBuild())
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
ItemStack heldItem = player.getItemInHand(handIn);
|
ItemStack heldItem = player.getItemInHand(handIn);
|
||||||
|
@ -403,18 +402,18 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
return shape;
|
return shape;
|
||||||
|
|
||||||
return getBlockEntityOptional(worldIn, pos).map(be -> {
|
return getBlockEntityOptional(worldIn, pos).map(be -> {
|
||||||
Entity entity = ((EntityCollisionContext) context).getEntity();
|
Entity entity = ((EntityCollisionContext) context).getEntity();
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
|
return shape;
|
||||||
|
|
||||||
|
BeltBlockEntity controller = be.getControllerBE();
|
||||||
|
if (controller == null)
|
||||||
|
return shape;
|
||||||
|
if (controller.passengers == null || !controller.passengers.containsKey(entity))
|
||||||
|
return BeltShapes.getCollisionShape(state);
|
||||||
return shape;
|
return shape;
|
||||||
|
|
||||||
BeltBlockEntity controller = be.getControllerBE();
|
})
|
||||||
if (controller == null)
|
|
||||||
return shape;
|
|
||||||
if (controller.passengers == null || !controller.passengers.containsKey(entity))
|
|
||||||
return BeltShapes.getCollisionShape(state);
|
|
||||||
return shape;
|
|
||||||
|
|
||||||
})
|
|
||||||
.orElse(shape);
|
.orElse(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,8 +461,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
BlockEntity blockEntity = world.getBlockEntity(beltPos);
|
BlockEntity blockEntity = world.getBlockEntity(beltPos);
|
||||||
BlockState currentState = world.getBlockState(beltPos);
|
BlockState currentState = world.getBlockState(beltPos);
|
||||||
|
|
||||||
if (blockEntity instanceof BeltBlockEntity && AllBlocks.BELT.has(currentState)) {
|
if (blockEntity instanceof BeltBlockEntity be && AllBlocks.BELT.has(currentState)) {
|
||||||
BeltBlockEntity be = (BeltBlockEntity) blockEntity;
|
|
||||||
be.setController(currentPos);
|
be.setController(currentPos);
|
||||||
be.beltLength = beltChain.size();
|
be.beltLength = beltChain.size();
|
||||||
be.index = index;
|
be.index = index;
|
||||||
|
@ -505,8 +503,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
boolean hasPulley = false;
|
boolean hasPulley = false;
|
||||||
BlockEntity blockEntity = world.getBlockEntity(currentPos);
|
BlockEntity blockEntity = world.getBlockEntity(currentPos);
|
||||||
if (blockEntity instanceof BeltBlockEntity) {
|
if (blockEntity instanceof BeltBlockEntity belt) {
|
||||||
BeltBlockEntity belt = (BeltBlockEntity) blockEntity;
|
|
||||||
if (belt.isController())
|
if (belt.isController())
|
||||||
belt.getInventory()
|
belt.getInventory()
|
||||||
.ejectAll();
|
.ejectAll();
|
||||||
|
@ -525,7 +522,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, LevelAccessor world,
|
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, LevelAccessor world,
|
||||||
BlockPos pos, BlockPos p_196271_6_) {
|
BlockPos pos, BlockPos p_196271_6_) {
|
||||||
updateWater(world, state, pos);
|
updateWater(world, state, pos);
|
||||||
if (side.getAxis()
|
if (side.getAxis()
|
||||||
.isHorizontal())
|
.isHorizontal())
|
||||||
|
@ -635,7 +632,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
return rotate;
|
return rotate;
|
||||||
if (state.getValue(HORIZONTAL_FACING)
|
if (state.getValue(HORIZONTAL_FACING)
|
||||||
.getAxisDirection() != rotate.getValue(HORIZONTAL_FACING)
|
.getAxisDirection() != rotate.getValue(HORIZONTAL_FACING)
|
||||||
.getAxisDirection()) {
|
.getAxisDirection()) {
|
||||||
if (state.getValue(PART) == BeltPart.START)
|
if (state.getValue(PART) == BeltPart.START)
|
||||||
return rotate.setValue(PART, BeltPart.END);
|
return rotate.setValue(PART, BeltPart.END);
|
||||||
if (state.getValue(PART) == BeltPart.END)
|
if (state.getValue(PART) == BeltPart.END)
|
||||||
|
|
|
@ -45,6 +45,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.client.model.data.ModelData;
|
import net.minecraftforge.client.model.data.ModelData;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
@ -389,7 +390,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyToAllItems(float maxDistanceFromCenter,
|
private void applyToAllItems(float maxDistanceFromCenter,
|
||||||
Function<TransportedItemStack, TransportedResult> processFunction) {
|
Function<TransportedItemStack, TransportedResult> processFunction) {
|
||||||
BeltBlockEntity controller = getControllerBE();
|
BeltBlockEntity controller = getControllerBE();
|
||||||
if (controller == null)
|
if (controller == null)
|
||||||
return;
|
return;
|
||||||
|
@ -472,8 +473,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
|
||||||
return inserted;
|
return inserted;
|
||||||
|
|
||||||
BlockEntity teAbove = level.getBlockEntity(worldPosition.above());
|
BlockEntity teAbove = level.getBlockEntity(worldPosition.above());
|
||||||
if (teAbove instanceof BrassTunnelBlockEntity) {
|
if (teAbove instanceof BrassTunnelBlockEntity tunnelBE) {
|
||||||
BrassTunnelBlockEntity tunnelBE = (BrassTunnelBlockEntity) teAbove;
|
|
||||||
if (tunnelBE.hasDistributionBehaviour()) {
|
if (tunnelBE.hasDistributionBehaviour()) {
|
||||||
if (!tunnelBE.getStackToDistribute()
|
if (!tunnelBE.getStackToDistribute()
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
|
@ -542,7 +542,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float propagateRotationTo(KineticBlockEntity target, BlockState stateFrom, BlockState stateTo, BlockPos diff,
|
public float propagateRotationTo(KineticBlockEntity target, BlockState stateFrom, BlockState stateTo, BlockPos diff,
|
||||||
boolean connectedViaAxes, boolean connectedViaCogs) {
|
boolean connectedViaAxes, boolean connectedViaCogs) {
|
||||||
if (target instanceof BeltBlockEntity && !connectedViaAxes)
|
if (target instanceof BeltBlockEntity && !connectedViaAxes)
|
||||||
return getController().equals(((BeltBlockEntity) target).getController()) ? 1 : 0;
|
return getController().equals(((BeltBlockEntity) target).getController()) ? 1 : 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -449,10 +449,9 @@ public class BeltSlicer {
|
||||||
public static void tickHoveringInformation() {
|
public static void tickHoveringInformation() {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
HitResult target = mc.hitResult;
|
HitResult target = mc.hitResult;
|
||||||
if (target == null || !(target instanceof BlockHitResult))
|
if (target == null || !(target instanceof BlockHitResult result))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockHitResult result = (BlockHitResult) target;
|
|
||||||
ClientLevel world = mc.level;
|
ClientLevel world = mc.level;
|
||||||
BlockPos pos = result.getBlockPos();
|
BlockPos pos = result.getBlockPos();
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
|
@ -11,66 +11,65 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
public class BeltCrusherInteractionHandler {
|
public class BeltCrusherInteractionHandler {
|
||||||
|
|
||||||
public static boolean checkForCrushers(BeltInventory beltInventory, TransportedItemStack currentItem,
|
public static boolean checkForCrushers(BeltInventory beltInventory, TransportedItemStack currentItem,
|
||||||
float nextOffset) {
|
float nextOffset) {
|
||||||
|
|
||||||
boolean beltMovementPositive = beltInventory.beltMovementPositive;
|
boolean beltMovementPositive = beltInventory.beltMovementPositive;
|
||||||
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
|
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
|
||||||
int step = beltMovementPositive ? 1 : -1;
|
int step = beltMovementPositive ? 1 : -1;
|
||||||
firstUpcomingSegment = Mth.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1);
|
firstUpcomingSegment = Mth.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1);
|
||||||
|
|
||||||
for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset
|
for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset
|
||||||
: segment + 1 >= nextOffset; segment += step) {
|
: segment + 1 >= nextOffset; segment += step) {
|
||||||
BlockPos crusherPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment)
|
BlockPos crusherPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment)
|
||||||
.above();
|
.above();
|
||||||
Level world = beltInventory.belt.getLevel();
|
Level world = beltInventory.belt.getLevel();
|
||||||
BlockState crusherState = world.getBlockState(crusherPos);
|
BlockState crusherState = world.getBlockState(crusherPos);
|
||||||
if (!(crusherState.getBlock() instanceof CrushingWheelControllerBlock))
|
if (!(crusherState.getBlock() instanceof CrushingWheelControllerBlock))
|
||||||
continue;
|
continue;
|
||||||
Direction crusherFacing = crusherState.getValue(CrushingWheelControllerBlock.FACING);
|
Direction crusherFacing = crusherState.getValue(CrushingWheelControllerBlock.FACING);
|
||||||
Direction movementFacing = beltInventory.belt.getMovementFacing();
|
Direction movementFacing = beltInventory.belt.getMovementFacing();
|
||||||
if (crusherFacing != movementFacing)
|
if (crusherFacing != movementFacing)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float crusherEntry = segment + .5f;
|
float crusherEntry = segment + .5f;
|
||||||
crusherEntry += .399f * (beltMovementPositive ? -1 : 1);
|
crusherEntry += .399f * (beltMovementPositive ? -1 : 1);
|
||||||
float postCrusherEntry = crusherEntry + .799f * (!beltMovementPositive ? -1 : 1);
|
float postCrusherEntry = crusherEntry + .799f * (!beltMovementPositive ? -1 : 1);
|
||||||
|
|
||||||
boolean hasCrossed = nextOffset > crusherEntry && nextOffset < postCrusherEntry && beltMovementPositive
|
boolean hasCrossed = nextOffset > crusherEntry && nextOffset < postCrusherEntry && beltMovementPositive
|
||||||
|| nextOffset < crusherEntry && nextOffset > postCrusherEntry && !beltMovementPositive;
|
|| nextOffset < crusherEntry && nextOffset > postCrusherEntry && !beltMovementPositive;
|
||||||
if (!hasCrossed)
|
if (!hasCrossed)
|
||||||
return false;
|
return false;
|
||||||
currentItem.beltPosition = crusherEntry;
|
currentItem.beltPosition = crusherEntry;
|
||||||
|
|
||||||
BlockEntity be = world.getBlockEntity(crusherPos);
|
BlockEntity be = world.getBlockEntity(crusherPos);
|
||||||
if (!(be instanceof CrushingWheelControllerBlockEntity))
|
if (!(be instanceof CrushingWheelControllerBlockEntity crusherBE))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CrushingWheelControllerBlockEntity crusherBE = (CrushingWheelControllerBlockEntity) be;
|
ItemStack toInsert = currentItem.stack.copy();
|
||||||
|
|
||||||
ItemStack toInsert = currentItem.stack.copy();
|
ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherBE.inventory, toInsert, false);
|
||||||
|
if (toInsert.equals(remainder, false))
|
||||||
|
return true;
|
||||||
|
|
||||||
ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherBE.inventory, toInsert, false);
|
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
|
||||||
if (toInsert.equals(remainder, false))
|
if (!remainder.isEmpty()) {
|
||||||
return true;
|
remainder.grow(notFilled);
|
||||||
|
} else if (notFilled > 0)
|
||||||
|
remainder = ItemHandlerHelper.copyStackWithSize(currentItem.stack, notFilled);
|
||||||
|
|
||||||
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
|
currentItem.stack = remainder;
|
||||||
if (!remainder.isEmpty()) {
|
beltInventory.belt.sendData();
|
||||||
remainder.grow(notFilled);
|
return true;
|
||||||
} else if (notFilled > 0)
|
}
|
||||||
remainder = ItemHandlerHelper.copyStackWithSize(currentItem.stack, notFilled);
|
|
||||||
|
|
||||||
currentItem.stack = remainder;
|
return false;
|
||||||
beltInventory.belt.sendData();
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,13 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
public class BeltFunnelInteractionHandler {
|
public class BeltFunnelInteractionHandler {
|
||||||
|
|
||||||
public static boolean checkForFunnels(BeltInventory beltInventory, TransportedItemStack currentItem,
|
public static boolean checkForFunnels(BeltInventory beltInventory, TransportedItemStack currentItem,
|
||||||
float nextOffset) {
|
float nextOffset) {
|
||||||
boolean beltMovementPositive = beltInventory.beltMovementPositive;
|
boolean beltMovementPositive = beltInventory.beltMovementPositive;
|
||||||
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
|
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
|
||||||
int step = beltMovementPositive ? 1 : -1;
|
int step = beltMovementPositive ? 1 : -1;
|
||||||
|
@ -59,10 +60,9 @@ public class BeltFunnelInteractionHandler {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockEntity be = world.getBlockEntity(funnelPos);
|
BlockEntity be = world.getBlockEntity(funnelPos);
|
||||||
if (!(be instanceof FunnelBlockEntity))
|
if (!(be instanceof FunnelBlockEntity funnelBE))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
FunnelBlockEntity funnelBE = (FunnelBlockEntity) be;
|
|
||||||
InvManipulationBehaviour inserting = funnelBE.getBehaviour(InvManipulationBehaviour.TYPE);
|
InvManipulationBehaviour inserting = funnelBE.getBehaviour(InvManipulationBehaviour.TYPE);
|
||||||
FilteringBehaviour filtering = funnelBE.getBehaviour(FilteringBehaviour.TYPE);
|
FilteringBehaviour filtering = funnelBE.getBehaviour(FilteringBehaviour.TYPE);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class BeltFunnelInteractionHandler {
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(beltInventory.belt.invVersionTracker.stillWaiting(inserting))
|
if (beltInventory.belt.invVersionTracker.stillWaiting(inserting))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int amountToExtract = funnelBE.getAmountToExtract();
|
int amountToExtract = funnelBE.getAmountToExtract();
|
||||||
|
|
|
@ -21,12 +21,13 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
public class BeltTunnelInteractionHandler {
|
public class BeltTunnelInteractionHandler {
|
||||||
|
|
||||||
public static boolean flapTunnelsAndCheckIfStuck(BeltInventory beltInventory, TransportedItemStack current,
|
public static boolean flapTunnelsAndCheckIfStuck(BeltInventory beltInventory, TransportedItemStack current,
|
||||||
float nextOffset) {
|
float nextOffset) {
|
||||||
|
|
||||||
int currentSegment = (int) current.beltPosition;
|
int currentSegment = (int) current.beltPosition;
|
||||||
int upcomingSegment = (int) nextOffset;
|
int upcomingSegment = (int) nextOffset;
|
||||||
|
@ -48,8 +49,7 @@ public class BeltTunnelInteractionHandler {
|
||||||
BeltTunnelBlockEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment);
|
BeltTunnelBlockEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment);
|
||||||
int transferred = current.stack.getCount();
|
int transferred = current.stack.getCount();
|
||||||
|
|
||||||
if (nextTunnel instanceof BrassTunnelBlockEntity) {
|
if (nextTunnel instanceof BrassTunnelBlockEntity brassTunnel) {
|
||||||
BrassTunnelBlockEntity brassTunnel = (BrassTunnelBlockEntity) nextTunnel;
|
|
||||||
if (brassTunnel.hasDistributionBehaviour()) {
|
if (brassTunnel.hasDistributionBehaviour()) {
|
||||||
if (!brassTunnel.canTakeItems())
|
if (!brassTunnel.canTakeItems())
|
||||||
return true;
|
return true;
|
||||||
|
@ -115,7 +115,7 @@ public class BeltTunnelInteractionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean stuckAtTunnel(BeltInventory beltInventory, int offset, ItemStack stack,
|
public static boolean stuckAtTunnel(BeltInventory beltInventory, int offset, ItemStack stack,
|
||||||
Direction movementDirection) {
|
Direction movementDirection) {
|
||||||
BeltBlockEntity belt = beltInventory.belt;
|
BeltBlockEntity belt = beltInventory.belt;
|
||||||
BlockPos pos = BeltHelper.getPositionForOffset(belt, offset)
|
BlockPos pos = BeltHelper.getPositionForOffset(belt, offset)
|
||||||
.above();
|
.above();
|
||||||
|
@ -125,9 +125,8 @@ public class BeltTunnelInteractionHandler {
|
||||||
return false;
|
return false;
|
||||||
BlockEntity be = belt.getLevel()
|
BlockEntity be = belt.getLevel()
|
||||||
.getBlockEntity(pos);
|
.getBlockEntity(pos);
|
||||||
if (be == null || !(be instanceof BrassTunnelBlockEntity))
|
if (be == null || !(be instanceof BrassTunnelBlockEntity tunnel))
|
||||||
return false;
|
return false;
|
||||||
BrassTunnelBlockEntity tunnel = (BrassTunnelBlockEntity) be;
|
|
||||||
return !tunnel.canInsert(movementDirection.getOpposite(), stack);
|
return !tunnel.canInsert(movementDirection.getOpposite(), stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,15 @@ package com.simibubi.create.content.kinetics.belt.transport;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllRegistries;
|
||||||
import com.simibubi.create.content.kinetics.belt.BeltHelper;
|
import com.simibubi.create.content.kinetics.belt.BeltHelper;
|
||||||
|
import com.simibubi.create.content.kinetics.fan.processing.AllFanProcessingTypes;
|
||||||
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
||||||
import com.simibubi.create.content.logistics.box.PackageItem;
|
import com.simibubi.create.content.logistics.box.PackageItem;
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
||||||
|
@ -77,6 +80,16 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
||||||
nbt.putInt("InSegment", insertedAt);
|
nbt.putInt("InSegment", insertedAt);
|
||||||
nbt.putInt("Angle", angle);
|
nbt.putInt("Angle", angle);
|
||||||
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
|
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
|
||||||
|
|
||||||
|
if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) {
|
||||||
|
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPE.get().getKey(processedBy);
|
||||||
|
if (key == null)
|
||||||
|
throw new IllegalArgumentException("Could not get id for FanProcessingType " + processedBy + "!");
|
||||||
|
|
||||||
|
nbt.putString("FanProcessingType", key.toString());
|
||||||
|
nbt.putInt("FanProcessingTime", processingTime);
|
||||||
|
}
|
||||||
|
|
||||||
if (locked)
|
if (locked)
|
||||||
nbt.putBoolean("Locked", locked);
|
nbt.putBoolean("Locked", locked);
|
||||||
if (lockedExternally)
|
if (lockedExternally)
|
||||||
|
@ -95,7 +108,18 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
||||||
stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection"));
|
stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection"));
|
||||||
stack.locked = nbt.getBoolean("Locked");
|
stack.locked = nbt.getBoolean("Locked");
|
||||||
stack.lockedExternally = nbt.getBoolean("LockedExternally");
|
stack.lockedExternally = nbt.getBoolean("LockedExternally");
|
||||||
|
|
||||||
|
if (nbt.contains("FanProcessingType")) {
|
||||||
|
stack.processedBy = AllFanProcessingTypes.parseLegacy(nbt.getString("FanProcessingType"));
|
||||||
|
stack.processingTime = nbt.getInt("FanProcessingTime");
|
||||||
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public void clearFanProcessingData() {
|
||||||
|
processedBy = null;
|
||||||
|
processingTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ChainConveyorPackage {
|
||||||
|
|
||||||
public void setBE(ChainConveyorBlockEntity ccbe) {
|
public void setBE(ChainConveyorBlockEntity ccbe) {
|
||||||
if (beReference == null || beReference.get() != ccbe)
|
if (beReference == null || beReference.get() != ccbe)
|
||||||
beReference = new WeakReference<ChainConveyorBlockEntity>(ccbe);
|
beReference = new WeakReference<>(ccbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
@ -125,7 +126,7 @@ public class ConnectedInputHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void connectControllers(Level world, MechanicalCrafterBlockEntity crafter1,
|
public static void connectControllers(Level world, MechanicalCrafterBlockEntity crafter1,
|
||||||
MechanicalCrafterBlockEntity crafter2) {
|
MechanicalCrafterBlockEntity crafter2) {
|
||||||
|
|
||||||
crafter1.input.data.forEach(offset -> {
|
crafter1.input.data.forEach(offset -> {
|
||||||
BlockPos connectedPos = crafter1.getBlockPos()
|
BlockPos connectedPos = crafter1.getBlockPos()
|
||||||
|
@ -151,10 +152,9 @@ public class ConnectedInputHandler {
|
||||||
|
|
||||||
private static void modifyAndUpdate(Level world, BlockPos pos, Consumer<ConnectedInput> callback) {
|
private static void modifyAndUpdate(Level world, BlockPos pos, Consumer<ConnectedInput> callback) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (!(blockEntity instanceof MechanicalCrafterBlockEntity))
|
if (!(blockEntity instanceof MechanicalCrafterBlockEntity crafter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MechanicalCrafterBlockEntity crafter = (MechanicalCrafterBlockEntity) blockEntity;
|
|
||||||
callback.accept(crafter.input);
|
callback.accept(crafter.input);
|
||||||
crafter.setChanged();
|
crafter.setChanged();
|
||||||
crafter.connectivityChanged();
|
crafter.connectivityChanged();
|
||||||
|
|
|
@ -5,17 +5,16 @@ import com.simibubi.create.AllPartialModels;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity;
|
import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.api.model.Model;
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
import dev.engine_room.flywheel.lib.model.Models;
|
|
||||||
import net.createmod.catnip.render.CachedBuffers;
|
import net.createmod.catnip.render.CachedBuffers;
|
||||||
import net.createmod.catnip.render.SuperByteBuffer;
|
import net.createmod.catnip.render.SuperByteBuffer;
|
||||||
import net.createmod.catnip.animation.AnimationTickHolder;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@ -49,9 +48,8 @@ public class HandCrankBlockEntity extends GeneratingKineticBlockEntity {
|
||||||
@Override
|
@Override
|
||||||
public float getGeneratedSpeed() {
|
public float getGeneratedSpeed() {
|
||||||
Block block = getBlockState().getBlock();
|
Block block = getBlockState().getBlock();
|
||||||
if (!(block instanceof HandCrankBlock))
|
if (!(block instanceof HandCrankBlock crank))
|
||||||
return 0;
|
return 0;
|
||||||
HandCrankBlock crank = (HandCrankBlock) block;
|
|
||||||
int speed = (inUse == 0 ? 0 : clockwise() ? -1 : 1) * crank.getRotationSpeed();
|
int speed = (inUse == 0 ? 0 : clockwise() ? -1 : 1) * crank.getRotationSpeed();
|
||||||
return convertToDirection(speed, getBlockState().getValue(HandCrankBlock.FACING));
|
return convertToDirection(speed, getBlockState().getValue(HandCrankBlock.FACING));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ import com.simibubi.create.foundation.sound.SoundScapes;
|
||||||
import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup;
|
import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup;
|
||||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||||
|
|
||||||
import net.createmod.catnip.nbt.NBTHelper;
|
|
||||||
import net.createmod.catnip.math.VecHelper;
|
import net.createmod.catnip.math.VecHelper;
|
||||||
|
import net.createmod.catnip.nbt.NBTHelper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
@ -39,6 +39,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
@ -114,10 +115,10 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
|
||||||
.getStep();
|
.getStep();
|
||||||
Vec3 outSpeed = new Vec3((facing.getAxis() == Axis.X ? 0.25D : 0.0D) * offset,
|
Vec3 outSpeed = new Vec3((facing.getAxis() == Axis.X ? 0.25D : 0.0D) * offset,
|
||||||
offset == 1 ? (facing.getAxis() == Axis.Y ? 0.5D : 0.0D) : 0.0D // Increased upwards speed so upwards
|
offset == 1 ? (facing.getAxis() == Axis.Y ? 0.5D : 0.0D) : 0.0D // Increased upwards speed so upwards
|
||||||
// crushing wheels shoot out the item
|
// crushing wheels shoot out the item
|
||||||
// properly.
|
// properly.
|
||||||
, (facing.getAxis() == Axis.Z ? 0.25D : 0.0D) * offset); // No downwards speed, so downwards crushing wheels
|
, (facing.getAxis() == Axis.Z ? 0.25D : 0.0D) * offset); // No downwards speed, so downwards crushing wheels
|
||||||
// drop the items as before.
|
// drop the items as before.
|
||||||
Vec3 outPos = centerPos.add((facing.getAxis() == Axis.X ? .55f * offset : 0f),
|
Vec3 outPos = centerPos.add((facing.getAxis() == Axis.X ? .55f * offset : 0f),
|
||||||
(facing.getAxis() == Axis.Y ? .55f * offset : 0f), (facing.getAxis() == Axis.Z ? .55f * offset : 0f));
|
(facing.getAxis() == Axis.Y ? .55f * offset : 0f), (facing.getAxis() == Axis.Z ? .55f * offset : 0f));
|
||||||
|
|
||||||
|
@ -202,32 +203,32 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
|
||||||
double movement = Math.max(-speed / 4f, -.5f) * -offset;
|
double movement = Math.max(-speed / 4f, -.5f) * -offset;
|
||||||
processingEntity.setDeltaMovement(
|
processingEntity.setDeltaMovement(
|
||||||
new Vec3(facing.getAxis() == Axis.X ? movement : xMotion, facing.getAxis() == Axis.Y ? movement : 0f // Do
|
new Vec3(facing.getAxis() == Axis.X ? movement : xMotion, facing.getAxis() == Axis.Y ? movement : 0f // Do
|
||||||
// not
|
// not
|
||||||
// move
|
// move
|
||||||
// entities
|
// entities
|
||||||
// upwards
|
// upwards
|
||||||
// or
|
// or
|
||||||
// downwards
|
// downwards
|
||||||
// for
|
// for
|
||||||
// horizontal
|
// horizontal
|
||||||
// crushers,
|
// crushers,
|
||||||
, facing.getAxis() == Axis.Z ? movement : zMotion)); // Or they'll only get their feet crushed.
|
, facing.getAxis() == Axis.Z ? movement : zMotion)); // Or they'll only get their feet crushed.
|
||||||
|
|
||||||
if (level.isClientSide)
|
if (level.isClientSide)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(processingEntity instanceof ItemEntity)) {
|
if (!(processingEntity instanceof ItemEntity itemEntity)) {
|
||||||
Vec3 entityOutPos = outPos.add(facing.getAxis() == Axis.X ? .5f * offset : 0f,
|
Vec3 entityOutPos = outPos.add(facing.getAxis() == Axis.X ? .5f * offset : 0f,
|
||||||
facing.getAxis() == Axis.Y ? .5f * offset : 0f, facing.getAxis() == Axis.Z ? .5f * offset : 0f);
|
facing.getAxis() == Axis.Y ? .5f * offset : 0f, facing.getAxis() == Axis.Z ? .5f * offset : 0f);
|
||||||
int crusherDamage = AllConfigs.server().kinetics.crushingDamage.get();
|
int crusherDamage = AllConfigs.server().kinetics.crushingDamage.get();
|
||||||
|
|
||||||
if (processingEntity instanceof LivingEntity) {
|
if (processingEntity instanceof LivingEntity) {
|
||||||
if ((((LivingEntity) processingEntity).getHealth() - crusherDamage <= 0) // Takes LivingEntity instances
|
if ((((LivingEntity) processingEntity).getHealth() - crusherDamage <= 0) // Takes LivingEntity instances
|
||||||
// as exception, so it can
|
// as exception, so it can
|
||||||
// move them before it would
|
// move them before it would
|
||||||
// kill them.
|
// kill them.
|
||||||
&& (((LivingEntity) processingEntity).hurtTime <= 0)) { // This way it can actually output the items
|
&& (((LivingEntity) processingEntity).hurtTime <= 0)) { // This way it can actually output the items
|
||||||
// to the right spot.
|
// to the right spot.
|
||||||
processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z);
|
processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +239,6 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemEntity itemEntity = (ItemEntity) processingEntity;
|
|
||||||
itemEntity.setPickUpDelay(20);
|
itemEntity.setPickUpDelay(20);
|
||||||
if (facing.getAxis() == Axis.Y) {
|
if (facing.getAxis() == Axis.Y) {
|
||||||
if (processingEntity.getY() * -offset < (centerPos.y - .25f) * -offset) {
|
if (processingEntity.getY() * -offset < (centerPos.y - .25f) * -offset) {
|
||||||
|
@ -301,8 +301,7 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
|
||||||
for (int roll = 0; roll < rolls; roll++) {
|
for (int roll = 0; roll < rolls; roll++) {
|
||||||
List<ItemStack> rolledResults = recipe.get()
|
List<ItemStack> rolledResults = recipe.get()
|
||||||
.rollResults();
|
.rollResults();
|
||||||
for (int i = 0; i < rolledResults.size(); i++) {
|
for (ItemStack stack : rolledResults) {
|
||||||
ItemStack stack = rolledResults.get(i);
|
|
||||||
ItemHelper.addToList(stack, list);
|
ItemHelper.addToList(stack, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,8 @@ public class BeltDeployerCallbacks {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
blockEntity.award(AllAdvancements.DEPLOYER);
|
blockEntity.award(AllAdvancements.DEPLOYER);
|
||||||
|
|
||||||
|
transported.clearFanProcessingData();
|
||||||
|
|
||||||
TransportedItemStack left = transported.copy();
|
TransportedItemStack left = transported.copy();
|
||||||
blockEntity.player.spawnedItemEffects = transported.stack.copy();
|
blockEntity.player.spawnedItemEffects = transported.stack.copy();
|
||||||
|
|
|
@ -35,6 +35,7 @@ import net.minecraft.world.entity.monster.Creeper;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.UsernameCache;
|
import net.minecraftforge.common.UsernameCache;
|
||||||
|
@ -121,8 +122,7 @@ public class DeployerFakePlayer extends FakePlayer {
|
||||||
public static void deployerCollectsDropsFromKilledEntities(LivingDropsEvent event) {
|
public static void deployerCollectsDropsFromKilledEntities(LivingDropsEvent event) {
|
||||||
DamageSource source = event.getSource();
|
DamageSource source = event.getSource();
|
||||||
Entity trueSource = source.getEntity();
|
Entity trueSource = source.getEntity();
|
||||||
if (trueSource != null && trueSource instanceof DeployerFakePlayer) {
|
if (trueSource != null && trueSource instanceof DeployerFakePlayer fakePlayer) {
|
||||||
DeployerFakePlayer fakePlayer = (DeployerFakePlayer) trueSource;
|
|
||||||
event.getDrops()
|
event.getDrops()
|
||||||
.forEach(stack -> fakePlayer.getInventory()
|
.forEach(stack -> fakePlayer.getInventory()
|
||||||
.placeItemBackInInventory(stack.getItem()));
|
.placeItemBackInInventory(stack.getItem()));
|
||||||
|
@ -158,7 +158,7 @@ public class DeployerFakePlayer extends FakePlayer {
|
||||||
|
|
||||||
CKinetics.DeployerAggroSetting setting = AllConfigs.server().kinetics.ignoreDeployerAttacks.get();
|
CKinetics.DeployerAggroSetting setting = AllConfigs.server().kinetics.ignoreDeployerAttacks.get();
|
||||||
|
|
||||||
switch(setting) {
|
switch (setting) {
|
||||||
case ALL -> event.setCanceled(true);
|
case ALL -> event.setCanceled(true);
|
||||||
case CREEPERS -> {
|
case CREEPERS -> {
|
||||||
if (mob instanceof Creeper)
|
if (mob instanceof Creeper)
|
||||||
|
@ -216,10 +216,12 @@ public class DeployerFakePlayer extends FakePlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(Packet<?> packetIn) {}
|
public void send(Packet<?> packetIn) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(Packet<?> p_243227_, @Nullable PacketSendListener p_243273_) {}
|
public void send(Packet<?> p_243227_, @Nullable PacketSendListener p_243273_) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.world.item.MobBucketItem;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -51,6 +49,7 @@ import net.minecraft.world.item.BucketItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.MobBucketItem;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
|
@ -69,6 +68,7 @@ import net.minecraft.world.level.material.Fluids;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.common.extensions.IForgeBaseRailBlock;
|
import net.minecraftforge.common.extensions.IForgeBaseRailBlock;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
|
||||||
|
@ -101,7 +101,7 @@ public class DeployerHandler {
|
||||||
if (rayMode && (pos.relative(face.getOpposite(), 3)
|
if (rayMode && (pos.relative(face.getOpposite(), 3)
|
||||||
.equals(position)
|
.equals(position)
|
||||||
|| pos.relative(face.getOpposite(), 1)
|
|| pos.relative(face.getOpposite(), 1)
|
||||||
.equals(position)))
|
.equals(position)))
|
||||||
return Blocks.BEDROCK.defaultBlockState();
|
return Blocks.BEDROCK.defaultBlockState();
|
||||||
return level.getBlockState(position);
|
return level.getBlockState(position);
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,7 @@ public class DeployerHandler {
|
||||||
.getBlock() == ((BlockItem) held.getItem()).getBlock())
|
.getBlock() == ((BlockItem) held.getItem()).getBlock())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (held.getItem() instanceof BucketItem) {
|
if (held.getItem() instanceof BucketItem bucketItem) {
|
||||||
BucketItem bucketItem = (BucketItem) held.getItem();
|
|
||||||
Fluid fluid = bucketItem.getFluid();
|
Fluid fluid = bucketItem.getFluid();
|
||||||
if (fluid != Fluids.EMPTY && world.getFluidState(targetPos)
|
if (fluid != Fluids.EMPTY && world.getFluidState(targetPos)
|
||||||
.getType() == fluid)
|
.getType() == fluid)
|
||||||
|
@ -139,7 +138,7 @@ public class DeployerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector,
|
private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector,
|
||||||
Mode mode) {
|
Mode mode) {
|
||||||
|
|
||||||
Vec3 rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f));
|
Vec3 rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f));
|
||||||
Vec3 rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f));
|
Vec3 rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f));
|
||||||
|
@ -171,15 +170,14 @@ public class DeployerHandler {
|
||||||
if (cancelResult == null) {
|
if (cancelResult == null) {
|
||||||
if (entity.interact(player, hand)
|
if (entity.interact(player, hand)
|
||||||
.consumesAction()) {
|
.consumesAction()) {
|
||||||
if (entity instanceof AbstractVillager) {
|
if (entity instanceof AbstractVillager villager) {
|
||||||
AbstractVillager villager = ((AbstractVillager) entity);
|
|
||||||
if (villager.getTradingPlayer() instanceof DeployerFakePlayer)
|
if (villager.getTradingPlayer() instanceof DeployerFakePlayer)
|
||||||
villager.setTradingPlayer(null);
|
villager.setTradingPlayer(null);
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
} else if (entity instanceof LivingEntity
|
} else if (entity instanceof LivingEntity
|
||||||
&& stack.interactLivingEntity(player, (LivingEntity) entity, hand)
|
&& stack.interactLivingEntity(player, (LivingEntity) entity, hand)
|
||||||
.consumesAction())
|
.consumesAction())
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
if (!success && entity instanceof Player playerEntity) {
|
if (!success && entity instanceof Player playerEntity) {
|
||||||
|
@ -412,14 +410,14 @@ public class DeployerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InteractionResult safeOnUse(BlockState state, Level world, BlockPos pos, Player player,
|
public static InteractionResult safeOnUse(BlockState state, Level world, BlockPos pos, Player player,
|
||||||
InteractionHand hand, BlockHitResult ray) {
|
InteractionHand hand, BlockHitResult ray) {
|
||||||
if (state.getBlock() instanceof BeehiveBlock)
|
if (state.getBlock() instanceof BeehiveBlock)
|
||||||
return safeOnBeehiveUse(state, world, pos, player, hand);
|
return safeOnBeehiveUse(state, world, pos, player, hand);
|
||||||
return state.use(world, player, hand, ray);
|
return state.use(world, player, hand, ray);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static InteractionResult safeOnBeehiveUse(BlockState state, Level world, BlockPos pos, Player player,
|
protected static InteractionResult safeOnBeehiveUse(BlockState state, Level world, BlockPos pos, Player player,
|
||||||
InteractionHand hand) {
|
InteractionHand hand) {
|
||||||
// <> BeehiveBlock#onUse
|
// <> BeehiveBlock#onUse
|
||||||
|
|
||||||
BeehiveBlock block = (BeehiveBlock) state.getBlock();
|
BeehiveBlock block = (BeehiveBlock) state.getBlock();
|
||||||
|
|
|
@ -21,12 +21,12 @@ import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||||
|
import net.createmod.catnip.animation.AnimationTickHolder;
|
||||||
|
import net.createmod.catnip.math.AngleHelper;
|
||||||
|
import net.createmod.catnip.math.VecHelper;
|
||||||
|
import net.createmod.catnip.nbt.NBTHelper;
|
||||||
import net.createmod.catnip.render.CachedBuffers;
|
import net.createmod.catnip.render.CachedBuffers;
|
||||||
import net.createmod.catnip.render.SuperByteBuffer;
|
import net.createmod.catnip.render.SuperByteBuffer;
|
||||||
import net.createmod.catnip.animation.AnimationTickHolder;
|
|
||||||
import net.createmod.catnip.nbt.NBTHelper;
|
|
||||||
import net.createmod.catnip.math.VecHelper;
|
|
||||||
import net.createmod.catnip.math.AngleHelper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
@ -50,7 +50,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
protected void renderSafe(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
renderItem(be, partialTicks, ms, buffer, light, overlay);
|
renderItem(be, partialTicks, ms, buffer, light, overlay);
|
||||||
FilteringRenderer.renderOnBlockEntity(be, partialTicks, ms, buffer, light, overlay);
|
FilteringRenderer.renderOnBlockEntity(be, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderItem(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
protected void renderItem(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (be.heldItem.isEmpty()) return;
|
if (be.heldItem.isEmpty()) return;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderComponents(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
protected void renderComponents(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||||
if (!VisualizationManager.supportsVisualization(be.getLevel())) {
|
if (!VisualizationManager.supportsVisualization(be.getLevel())) {
|
||||||
KineticBlockEntityRenderer.renderRotatingKineticBlock(be, getRenderedBlockState(be), ms, vb, light);
|
KineticBlockEntityRenderer.renderRotatingKineticBlock(be, getRenderedBlockState(be), ms, vb, light);
|
||||||
|
@ -155,7 +155,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
||||||
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
|
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
|
||||||
BlockState blockState = context.state;
|
BlockState blockState = context.state;
|
||||||
Mode mode = NBTHelper.readEnum(context.blockEntityData, "Mode", Mode.class);
|
Mode mode = NBTHelper.readEnum(context.blockEntityData, "Mode", Mode.class);
|
||||||
|
@ -188,8 +188,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
|
|
||||||
m.pushPose();
|
m.pushPose();
|
||||||
Direction.Axis axis = Direction.Axis.Y;
|
Direction.Axis axis = Direction.Axis.Y;
|
||||||
if (context.state.getBlock() instanceof IRotate) {
|
if (context.state.getBlock() instanceof IRotate def) {
|
||||||
IRotate def = (IRotate) context.state.getBlock();
|
|
||||||
axis = def.getRotationAxis(context.state);
|
axis = def.getRotationAxis(context.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class AirCurrent {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tickAffectedEntities(Level world) {
|
protected void tickAffectedEntities(Level world) {
|
||||||
for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext();) {
|
for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext(); ) {
|
||||||
Entity entity = iterator.next();
|
Entity entity = iterator.next();
|
||||||
if (!entity.isAlive() || !entity.getBoundingBox()
|
if (!entity.isAlive() || !entity.getBoundingBox()
|
||||||
.intersects(bounds) || isPlayerCreativeFlying(entity)) {
|
.intersects(bounds) || isPlayerCreativeFlying(entity)) {
|
||||||
|
@ -129,8 +129,7 @@ public class AirCurrent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerCreativeFlying(Entity entity) {
|
public static boolean isPlayerCreativeFlying(Entity entity) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player player) {
|
||||||
Player player = (Player) entity;
|
|
||||||
return player.isCreative() && player.getAbilities().flying;
|
return player.isCreative() && player.getAbilities().flying;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -143,7 +142,7 @@ public class AirCurrent {
|
||||||
FanProcessingType processingType = pair.getRight();
|
FanProcessingType processingType = pair.getRight();
|
||||||
if (processingType == AllFanProcessingTypes.NONE)
|
if (processingType == AllFanProcessingTypes.NONE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
handler.handleProcessingOnAllItems(transported -> {
|
handler.handleProcessingOnAllItems(transported -> {
|
||||||
if (world.isClientSide) {
|
if (world.isClientSide) {
|
||||||
processingType.spawnProcessingParticles(world, handler.getWorldPositionOf(transported));
|
processingType.spawnProcessingParticles(world, handler.getWorldPositionOf(transported));
|
||||||
|
@ -251,18 +250,18 @@ public class AirCurrent {
|
||||||
if (shapeDepth == Double.POSITIVE_INFINITY) {
|
if (shapeDepth == Double.POSITIVE_INFINITY) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return Math.min((float) (i + shapeDepth + 1/32d), max);
|
return Math.min((float) (i + shapeDepth + 1 / 32d), max);
|
||||||
}
|
}
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final double[][] DEPTH_TEST_COORDINATES = {
|
private static final double[][] DEPTH_TEST_COORDINATES = {
|
||||||
{ 0.25, 0.25 },
|
{0.25, 0.25},
|
||||||
{ 0.25, 0.75 },
|
{0.25, 0.75},
|
||||||
{ 0.5, 0.5 },
|
{0.5, 0.5},
|
||||||
{ 0.75, 0.25 },
|
{0.75, 0.25},
|
||||||
{ 0.75, 0.75 }
|
{0.75, 0.75}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Finds the maximum depth of the shape when traveling in the given direction.
|
// Finds the maximum depth of the shape when traveling in the given direction.
|
||||||
|
|
|
@ -14,21 +14,22 @@ import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
import net.minecraft.core.particles.ParticleOptions;
|
||||||
import net.minecraft.core.particles.ParticleType;
|
import net.minecraft.core.particles.ParticleType;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
public class AirFlowParticleData implements ParticleOptions, ICustomParticleDataWithSprite<AirFlowParticleData> {
|
public class AirFlowParticleData implements ParticleOptions, ICustomParticleDataWithSprite<AirFlowParticleData> {
|
||||||
|
|
||||||
public static final Codec<AirFlowParticleData> CODEC = RecordCodecBuilder.create(i ->
|
|
||||||
i.group(
|
|
||||||
Codec.INT.fieldOf("x").forGetter(p -> p.posX),
|
|
||||||
Codec.INT.fieldOf("y").forGetter(p -> p.posY),
|
|
||||||
Codec.INT.fieldOf("z").forGetter(p -> p.posZ))
|
|
||||||
.apply(i, AirFlowParticleData::new));
|
|
||||||
|
|
||||||
public static final ParticleOptions.Deserializer<AirFlowParticleData> DESERIALIZER = new ParticleOptions.Deserializer<AirFlowParticleData>() {
|
public static final Codec<AirFlowParticleData> CODEC = RecordCodecBuilder.create(i ->
|
||||||
|
i.group(
|
||||||
|
Codec.INT.fieldOf("x").forGetter(p -> p.posX),
|
||||||
|
Codec.INT.fieldOf("y").forGetter(p -> p.posY),
|
||||||
|
Codec.INT.fieldOf("z").forGetter(p -> p.posZ))
|
||||||
|
.apply(i, AirFlowParticleData::new));
|
||||||
|
|
||||||
|
public static final ParticleOptions.Deserializer<AirFlowParticleData> DESERIALIZER = new ParticleOptions.Deserializer<>() {
|
||||||
public AirFlowParticleData fromCommand(ParticleType<AirFlowParticleData> particleTypeIn, StringReader reader)
|
public AirFlowParticleData fromCommand(ParticleType<AirFlowParticleData> particleTypeIn, StringReader reader)
|
||||||
throws CommandSyntaxException {
|
throws CommandSyntaxException {
|
||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
int x = reader.readInt();
|
int x = reader.readInt();
|
||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
|
@ -82,7 +83,7 @@ public class AirFlowParticleData implements ParticleOptions, ICustomParticleData
|
||||||
public Deserializer<AirFlowParticleData> getDeserializer() {
|
public Deserializer<AirFlowParticleData> getDeserializer() {
|
||||||
return DESERIALIZER;
|
return DESERIALIZER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Codec<AirFlowParticleData> getCodec(ParticleType<AirFlowParticleData> type) {
|
public Codec<AirFlowParticleData> getCodec(ParticleType<AirFlowParticleData> type) {
|
||||||
return CODEC;
|
return CODEC;
|
||||||
|
@ -94,4 +95,4 @@ public class AirFlowParticleData implements ParticleOptions, ICustomParticleData
|
||||||
return AirFlowParticle.Factory::new;
|
return AirFlowParticle.Factory::new;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class EncasedFanBlockEntity extends KineticBlockEntity implements IAirCur
|
||||||
super.addBehaviours(behaviours);
|
super.addBehaviours(behaviours);
|
||||||
registerAwardables(behaviours, AllAdvancements.ENCASED_FAN, AllAdvancements.FAN_PROCESSING);
|
registerAwardables(behaviours, AllAdvancements.ENCASED_FAN, AllAdvancements.FAN_PROCESSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void read(CompoundTag compound, boolean clientPacket) {
|
protected void read(CompoundTag compound, boolean clientPacket) {
|
||||||
super.read(compound, clientPacket);
|
super.read(compound, clientPacket);
|
||||||
|
@ -89,7 +89,7 @@ public class EncasedFanBlockEntity extends KineticBlockEntity implements IAirCur
|
||||||
super.remove();
|
super.remove();
|
||||||
updateChute();
|
updateChute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSourceRemoved() {
|
public boolean isSourceRemoved() {
|
||||||
return remove;
|
return remove;
|
||||||
|
@ -108,9 +108,8 @@ public class EncasedFanBlockEntity extends KineticBlockEntity implements IAirCur
|
||||||
.isVertical())
|
.isVertical())
|
||||||
return;
|
return;
|
||||||
BlockEntity poweredChute = level.getBlockEntity(worldPosition.relative(direction));
|
BlockEntity poweredChute = level.getBlockEntity(worldPosition.relative(direction));
|
||||||
if (!(poweredChute instanceof ChuteBlockEntity))
|
if (!(poweredChute instanceof ChuteBlockEntity chuteBE))
|
||||||
return;
|
return;
|
||||||
ChuteBlockEntity chuteBE = (ChuteBlockEntity) poweredChute;
|
|
||||||
if (direction == Direction.DOWN)
|
if (direction == Direction.DOWN)
|
||||||
chuteBE.updatePull();
|
chuteBE.updatePull();
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,7 +39,8 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {}
|
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void write(CompoundTag compound, boolean clientPacket) {
|
protected void write(CompoundTag compound, boolean clientPacket) {
|
||||||
|
@ -86,10 +87,10 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
|
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext(); ) {
|
||||||
Entity entity = iterator.next();
|
Entity entity = iterator.next();
|
||||||
Vec3 diff = entity.position()
|
Vec3 diff = entity.position()
|
||||||
.subtract(center);
|
.subtract(center);
|
||||||
|
|
||||||
if (!(entity instanceof Player) && level.isClientSide)
|
if (!(entity instanceof Player) && level.isClientSide)
|
||||||
continue;
|
continue;
|
||||||
|
@ -105,7 +106,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
|
|
||||||
float factor = (entity instanceof ItemEntity) ? 1 / 128f : 1 / 32f;
|
float factor = (entity instanceof ItemEntity) ? 1 / 128f : 1 / 32f;
|
||||||
Vec3 pushVec = diff.normalize()
|
Vec3 pushVec = diff.normalize()
|
||||||
.scale((range - distance) * (pushing ? 1 : -1));
|
.scale((range - distance) * (pushing ? 1 : -1));
|
||||||
entity.setDeltaMovement(entity.getDeltaMovement()
|
entity.setDeltaMovement(entity.getDeltaMovement()
|
||||||
.add(pushVec.scale(factor)));
|
.add(pushVec.scale(factor)));
|
||||||
entity.fallDistance = 0;
|
entity.fallDistance = 0;
|
||||||
|
@ -123,10 +124,9 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
|
|
||||||
private float calcRange() {
|
private float calcRange() {
|
||||||
BlockEntity be = level.getBlockEntity(fanPos);
|
BlockEntity be = level.getBlockEntity(fanPos);
|
||||||
if (!(be instanceof IAirCurrentSource))
|
if (!(be instanceof IAirCurrentSource source))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
IAirCurrentSource source = (IAirCurrentSource) be;
|
|
||||||
if (source.getAirCurrent() == null)
|
if (source.getAirCurrent() == null)
|
||||||
return 0;
|
return 0;
|
||||||
if (source.getSpeed() == 0)
|
if (source.getSpeed() == 0)
|
||||||
|
@ -147,7 +147,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
|
|
||||||
for (Entity entity : level.getEntitiesOfClass(Entity.class, bb)) {
|
for (Entity entity : level.getEntitiesOfClass(Entity.class, bb)) {
|
||||||
Vec3 diff = entity.position()
|
Vec3 diff = entity.position()
|
||||||
.subtract(center);
|
.subtract(center);
|
||||||
|
|
||||||
double distance = diff.length();
|
double distance = diff.length();
|
||||||
if (distance > range || entity.isShiftKeyDown() || AirCurrent.isPlayerCreativeFlying(entity))
|
if (distance > range || entity.isShiftKeyDown() || AirCurrent.isPlayerCreativeFlying(entity))
|
||||||
|
@ -163,7 +163,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
pushingEntities.add(entity);
|
pushingEntities.add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
|
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext(); ) {
|
||||||
Entity entity = iterator.next();
|
Entity entity = iterator.next();
|
||||||
if (entity.isAlive())
|
if (entity.isAlive())
|
||||||
continue;
|
continue;
|
||||||
|
@ -172,7 +172,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
|
||||||
|
|
||||||
if (!pushing && pushingEntities.size() > 256 && !level.isClientSide) {
|
if (!pushing && pushingEntities.size() > 256 && !level.isClientSide) {
|
||||||
level.explode(null, center.x, center.y, center.z, 2, ExplosionInteraction.NONE);
|
level.explode(null, center.x, center.y, center.z, 2, ExplosionInteraction.NONE);
|
||||||
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
|
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext(); ) {
|
||||||
Entity entity = iterator.next();
|
Entity entity = iterator.next();
|
||||||
entity.discard();
|
entity.discard();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
|
|
@ -60,7 +60,7 @@ import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
|
||||||
public class AllFanProcessingTypes {
|
public class AllFanProcessingTypes {
|
||||||
private static final DeferredRegister<FanProcessingType> REGISTER = DeferredRegister.create(AllRegistries.Keys.FAN_PROCESSING_TYPES, Create.ID);
|
private static final DeferredRegister<FanProcessingType> REGISTER = DeferredRegister.create(AllRegistries.Keys.FAN_PROCESSING_TYPE, Create.ID);
|
||||||
|
|
||||||
public static final NoneType NONE = register("none", new NoneType());
|
public static final NoneType NONE = register("none", new NoneType());
|
||||||
public static final BlastingType BLASTING = register("blasting", new BlastingType());
|
public static final BlastingType BLASTING = register("blasting", new BlastingType());
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class FanProcessing {
|
||||||
CompoundTag processing = createData.getCompound("Processing");
|
CompoundTag processing = createData.getCompound("Processing");
|
||||||
|
|
||||||
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
|
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
|
||||||
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPES.get().getKey(type);
|
ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPE.get().getKey(type);
|
||||||
if (key == null)
|
if (key == null)
|
||||||
throw new IllegalArgumentException("Could not get id for FanProcessingType " + type + "!");
|
throw new IllegalArgumentException("Could not get id for FanProcessingType " + type + "!");
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public interface FanProcessingType {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return AllFanProcessingTypes.NONE;
|
return AllFanProcessingTypes.NONE;
|
||||||
}
|
}
|
||||||
FanProcessingType type = AllRegistries.FAN_PROCESSING_TYPES.get().getValue(id);
|
FanProcessingType type = AllRegistries.FAN_PROCESSING_TYPE.get().getValue(id);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return AllFanProcessingTypes.NONE;
|
return AllFanProcessingTypes.NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.simibubi.create.content.kinetics.fan.processing;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.UnmodifiableView;
|
||||||
|
|
||||||
import com.simibubi.create.AllRegistries;
|
import com.simibubi.create.AllRegistries;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||||
|
|
||||||
import org.jetbrains.annotations.UnmodifiableView;
|
|
||||||
|
|
||||||
public class FanProcessingTypeRegistry {
|
public class FanProcessingTypeRegistry {
|
||||||
private static List<FanProcessingType> sortedTypes = null;
|
private static List<FanProcessingType> sortedTypes = null;
|
||||||
@UnmodifiableView
|
@UnmodifiableView
|
||||||
|
@ -19,7 +19,7 @@ public class FanProcessingTypeRegistry {
|
||||||
if (sortedTypes == null) {
|
if (sortedTypes == null) {
|
||||||
sortedTypes = new ReferenceArrayList<>();
|
sortedTypes = new ReferenceArrayList<>();
|
||||||
|
|
||||||
sortedTypes.addAll(AllRegistries.FAN_PROCESSING_TYPES.get().getValues());
|
sortedTypes.addAll(AllRegistries.FAN_PROCESSING_TYPE.get().getValues());
|
||||||
sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority());
|
sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority());
|
||||||
|
|
||||||
sortedTypesView = Collections.unmodifiableList(sortedTypes);
|
sortedTypesView = Collections.unmodifiableList(sortedTypes);
|
||||||
|
|
|
@ -8,9 +8,9 @@ import com.simibubi.create.content.kinetics.base.IRotate;
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
|
|
||||||
import net.createmod.catnip.data.Iterate;
|
import net.createmod.catnip.data.Iterate;
|
||||||
import net.createmod.catnip.math.VecHelper;
|
|
||||||
import net.createmod.catnip.lang.Lang;
|
import net.createmod.catnip.lang.Lang;
|
||||||
import net.createmod.catnip.levelWrappers.WrappedLevel;
|
import net.createmod.catnip.levelWrappers.WrappedLevel;
|
||||||
|
import net.createmod.catnip.math.VecHelper;
|
||||||
import net.createmod.catnip.theme.Color;
|
import net.createmod.catnip.theme.Color;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
@ -121,9 +121,8 @@ public class GaugeBlock extends DirectionalAxisKineticBlock implements IBE<Gauge
|
||||||
@Override
|
@Override
|
||||||
public void animateTick(BlockState stateIn, Level worldIn, BlockPos pos, RandomSource rand) {
|
public void animateTick(BlockState stateIn, Level worldIn, BlockPos pos, RandomSource rand) {
|
||||||
BlockEntity be = worldIn.getBlockEntity(pos);
|
BlockEntity be = worldIn.getBlockEntity(pos);
|
||||||
if (be == null || !(be instanceof GaugeBlockEntity))
|
if (be == null || !(be instanceof GaugeBlockEntity gaugeBE))
|
||||||
return;
|
return;
|
||||||
GaugeBlockEntity gaugeBE = (GaugeBlockEntity) be;
|
|
||||||
if (gaugeBE.dialTarget == 0)
|
if (gaugeBE.dialTarget == 0)
|
||||||
return;
|
return;
|
||||||
int color = gaugeBE.color;
|
int color = gaugeBE.color;
|
||||||
|
@ -169,8 +168,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock implements IBE<Gauge
|
||||||
@Override
|
@Override
|
||||||
public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) {
|
public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) {
|
||||||
BlockEntity be = worldIn.getBlockEntity(pos);
|
BlockEntity be = worldIn.getBlockEntity(pos);
|
||||||
if (be instanceof GaugeBlockEntity) {
|
if (be instanceof GaugeBlockEntity gaugeBlockEntity) {
|
||||||
GaugeBlockEntity gaugeBlockEntity = (GaugeBlockEntity) be;
|
|
||||||
return Mth.ceil(Mth.clamp(gaugeBlockEntity.dialTarget * 14, 0, 15));
|
return Mth.ceil(Mth.clamp(gaugeBlockEntity.dialTarget * 14, 0, 15));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -4,14 +4,10 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.AllRegistries;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.AllRegistries;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||||
import com.simibubi.create.content.kinetics.belt.BeltBlock;
|
import com.simibubi.create.content.kinetics.belt.BeltBlock;
|
||||||
|
@ -44,7 +40,6 @@ import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.world.Containers;
|
import net.minecraft.world.Containers;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.WorldlyContainer;
|
import net.minecraft.world.WorldlyContainer;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.RecordItem;
|
import net.minecraft.world.item.RecordItem;
|
||||||
|
@ -61,12 +56,15 @@ import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
|
||||||
public class AllArmInteractionPointTypes {
|
public class AllArmInteractionPointTypes {
|
||||||
private static final DeferredRegister<ArmInteractionPointType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPES, Create.ID);
|
private static final DeferredRegister<ArmInteractionPointType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPE, Create.ID);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
register("basin", new BasinType());
|
register("basin", new BasinType());
|
||||||
|
@ -202,7 +200,7 @@ public class AllArmInteractionPointTypes {
|
||||||
return state.getBlock() instanceof AbstractFunnelBlock
|
return state.getBlock() instanceof AbstractFunnelBlock
|
||||||
&& !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING))
|
&& !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING))
|
||||||
&& !(state.hasProperty(BeltFunnelBlock.SHAPE)
|
&& !(state.hasProperty(BeltFunnelBlock.SHAPE)
|
||||||
&& state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING);
|
&& state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -300,12 +298,13 @@ public class AllArmInteractionPointTypes {
|
||||||
|
|
||||||
public static class DepositOnlyArmInteractionPoint extends ArmInteractionPoint {
|
public static class DepositOnlyArmInteractionPoint extends ArmInteractionPoint {
|
||||||
public DepositOnlyArmInteractionPoint(ArmInteractionPointType type, Level level, BlockPos pos,
|
public DepositOnlyArmInteractionPoint(ArmInteractionPointType type, Level level, BlockPos pos,
|
||||||
BlockState state) {
|
BlockState state) {
|
||||||
super(type, level, pos, state);
|
super(type, level, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cycleMode() {}
|
public void cycleMode() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extract(int slot, int amount, boolean simulate) {
|
public ItemStack extract(int slot, int amount, boolean simulate) {
|
||||||
|
@ -406,9 +405,8 @@ public class AllArmInteractionPointTypes {
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extract(int slot, int amount, boolean simulate) {
|
public ItemStack extract(int slot, int amount, boolean simulate) {
|
||||||
BlockEntity be = level.getBlockEntity(pos);
|
BlockEntity be = level.getBlockEntity(pos);
|
||||||
if (!(be instanceof MechanicalCrafterBlockEntity))
|
if (!(be instanceof MechanicalCrafterBlockEntity crafter))
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
MechanicalCrafterBlockEntity crafter = (MechanicalCrafterBlockEntity) be;
|
|
||||||
SmartInventory inventory = crafter.getInventory();
|
SmartInventory inventory = crafter.getInventory();
|
||||||
inventory.allowExtraction();
|
inventory.allowExtraction();
|
||||||
ItemStack extract = super.extract(slot, amount, simulate);
|
ItemStack extract = super.extract(slot, amount, simulate);
|
||||||
|
@ -500,8 +498,7 @@ public class AllArmInteractionPointTypes {
|
||||||
ItemStack insert = inserter.insert(stack);
|
ItemStack insert = inserter.insert(stack);
|
||||||
if (!simulate && insert.getCount() != stack.getCount()) {
|
if (!simulate && insert.getCount() != stack.getCount()) {
|
||||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||||
if (blockEntity instanceof FunnelBlockEntity) {
|
if (blockEntity instanceof FunnelBlockEntity funnelBlockEntity) {
|
||||||
FunnelBlockEntity funnelBlockEntity = (FunnelBlockEntity) blockEntity;
|
|
||||||
funnelBlockEntity.onTransfer(stack);
|
funnelBlockEntity.onTransfer(stack);
|
||||||
if (funnelBlockEntity.hasFlap())
|
if (funnelBlockEntity.hasFlap())
|
||||||
funnelBlockEntity.flap(true);
|
funnelBlockEntity.flap(true);
|
||||||
|
@ -666,7 +663,7 @@ public class AllArmInteractionPointTypes {
|
||||||
@Override
|
@Override
|
||||||
protected Vec3 getInteractionPositionVector() {
|
protected Vec3 getInteractionPositionVector() {
|
||||||
return Vec3.atLowerCornerOf(pos)
|
return Vec3.atLowerCornerOf(pos)
|
||||||
.add(.5f, 1, .5f);
|
.add(.5f, 1, .5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements TransformableB
|
||||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||||
super.addBehaviours(behaviours);
|
super.addBehaviours(behaviours);
|
||||||
|
|
||||||
selectionMode = new ScrollOptionBehaviour<SelectionMode>(SelectionMode.class,
|
selectionMode = new ScrollOptionBehaviour<>(SelectionMode.class,
|
||||||
CreateLang.translateDirect("logistics.when_multiple_outputs_available"), this, new SelectionModeValueBox());
|
CreateLang.translateDirect("logistics.when_multiple_outputs_available"), this, new SelectionModeValueBox());
|
||||||
behaviours.add(selectionMode);
|
behaviours.add(selectionMode);
|
||||||
|
|
||||||
|
@ -262,7 +262,8 @@ public class ArmBlockEntity extends KineticBlockEntity implements TransformableB
|
||||||
if (scanRange > inputs.size())
|
if (scanRange > inputs.size())
|
||||||
scanRange = inputs.size();
|
scanRange = inputs.size();
|
||||||
|
|
||||||
InteractionPoints: for (int i = startIndex; i < scanRange; i++) {
|
InteractionPoints:
|
||||||
|
for (int i = startIndex; i < scanRange; i++) {
|
||||||
ArmInteractionPoint armInteractionPoint = inputs.get(i);
|
ArmInteractionPoint armInteractionPoint = inputs.get(i);
|
||||||
if (!armInteractionPoint.isValid())
|
if (!armInteractionPoint.isValid())
|
||||||
continue;
|
continue;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue