mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-22 08:30:01 +01:00
You wrenched this? I wrenched this.
- Fix NPE in CarriageSyncData (Unknown cause) - Fixed crash when applying text to display boards before they initialise - Fixed incorrect itemstack remainders on Weighted Ejectors - Other mods' wrenches now always behave like the Create wrench on IWrenchables
This commit is contained in:
parent
1188071b9a
commit
40f96b0038
6 changed files with 80 additions and 10 deletions
|
@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
|
|||
org.gradle.daemon = false
|
||||
|
||||
# mod version info
|
||||
mod_version = 0.5.0.i
|
||||
mod_version = 0.5.0.j
|
||||
artifact_minecraft_version = 1.18.2
|
||||
|
||||
minecraft_version = 1.18.2
|
||||
|
|
|
@ -67,7 +67,7 @@ public class Create {
|
|||
|
||||
public static final String ID = "create";
|
||||
public static final String NAME = "Create";
|
||||
public static final String VERSION = "0.5i";
|
||||
public static final String VERSION = "0.5j";
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.simibubi.create.content.contraptions.wrench;
|
||||
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class WrenchEventHandler {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void useOwnWrenchLogicForCreateBlocks(PlayerInteractEvent.RightClickBlock event) {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = event.getItemStack();
|
||||
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
if (event.getWorld() == null)
|
||||
return;
|
||||
if (player == null || !player.mayBuild())
|
||||
return;
|
||||
if (itemStack.isEmpty())
|
||||
return;
|
||||
if (AllItems.WRENCH.isIn(itemStack))
|
||||
return;
|
||||
if (!AllItemTags.WRENCH.matches(itemStack.getItem()))
|
||||
return;
|
||||
|
||||
BlockState state = event.getWorld()
|
||||
.getBlockState(event.getPos());
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (!(block instanceof IWrenchable))
|
||||
return;
|
||||
|
||||
BlockHitResult hitVec = event.getHitVec();
|
||||
UseOnContext context = new UseOnContext(player, event.getHand(), hitVec);
|
||||
IWrenchable actor = (IWrenchable) block;
|
||||
|
||||
InteractionResult result =
|
||||
player.isShiftKeyDown() ? actor.onSneakWrenched(state, context) : actor.onWrenched(state, context);
|
||||
event.setCanceled(true);
|
||||
event.setCancellationResult(result);
|
||||
}
|
||||
|
||||
}
|
|
@ -209,7 +209,7 @@ public class EjectorTileEntity extends KineticTileEntity {
|
|||
;
|
||||
else if (remainder.isEmpty())
|
||||
depotBehaviour.removeHeldItem();
|
||||
else if (!remainder.sameItem(heldItemStack))
|
||||
else if (remainder.getCount() != heldItemStack.getCount())
|
||||
depotBehaviour.heldItem.stack = remainder;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,7 @@ public class CarriageSyncData {
|
|||
|
||||
TrackGraph graph = carriage.train.graph;
|
||||
if (graph == null) {
|
||||
fallbackLocations = Pair.of(dce.positionAnchor, dce.rotationAnchors);
|
||||
dce.pointsInitialised = true;
|
||||
setDirty(true);
|
||||
updateFallbackLocations(dce);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -129,13 +127,19 @@ public class CarriageSyncData {
|
|||
for (boolean first : Iterate.trueAndFalse) {
|
||||
if (!first && !carriage.isOnTwoBogeys())
|
||||
break;
|
||||
|
||||
CarriageBogey bogey = carriage.bogeys.get(first);
|
||||
for (boolean firstPoint : Iterate.trueAndFalse) {
|
||||
TravellingPoint point = bogey.points.get(firstPoint);
|
||||
int index = (first ? 0 : 2) + (firstPoint ? 0 : 1);
|
||||
Pair<Couple<Integer>, Float> pair =
|
||||
Pair.of(Couple.create(point.node1.getNetId(), point.node2.getNetId()), (float) point.position);
|
||||
wheelLocations.set(index, pair);
|
||||
Couple<TrackNode> nodes = Couple.create(point.node1, point.node2);
|
||||
|
||||
if (nodes.either(Objects::isNull)) {
|
||||
updateFallbackLocations(dce);
|
||||
return;
|
||||
}
|
||||
|
||||
wheelLocations.set(index, Pair.of(nodes.map(TrackNode::getNetId), (float) point.position));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +147,12 @@ public class CarriageSyncData {
|
|||
setDirty(true);
|
||||
}
|
||||
|
||||
private void updateFallbackLocations(DimensionalCarriageEntity dce) {
|
||||
fallbackLocations = Pair.of(dce.positionAnchor, dce.rotationAnchors);
|
||||
dce.pointsInitialised = true;
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
public void apply(CarriageContraptionEntity entity, Carriage carriage) {
|
||||
DimensionalCarriageEntity dce = carriage.getDimensional(entity.level);
|
||||
|
||||
|
|
|
@ -137,7 +137,11 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
public void applyTextManually(int lineIndex, String rawComponentText) {
|
||||
FlapDisplayLayout layout = getLines().get(lineIndex);
|
||||
List<FlapDisplayLayout> lines = getLines();
|
||||
if (lineIndex >= lines.size())
|
||||
return;
|
||||
|
||||
FlapDisplayLayout layout = lines.get(lineIndex);
|
||||
if (!layout.isLayout("Default"))
|
||||
layout.loadDefault(getMaxCharCount());
|
||||
List<FlapDisplaySection> sections = layout.getSections();
|
||||
|
|
Loading…
Add table
Reference in a new issue