Skip to content

Commit

Permalink
Fix rail editing logic fired for items other than brush
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed May 11, 2023
1 parent 281ea94 commit aa88351
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,8 @@ public void onClose() {
}
}

@Override
public boolean isPauseScreen() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,9 @@ public void render(PoseStack matrixStack,
this.width / 2, TITLE_HEIGHT, 0xFFFFFF);
super.render(matrixStack, mouseX, mouseY, partialTicks);
}

@Override
public boolean isPauseScreen() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,9 @@ public void onClose() {
this.minecraft.setScreen(null);
}
}

@Override
public boolean isPauseScreen() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,32 @@ public ItemWithCreativeTabBaseMixin(Properties properties) {

@Override
public InteractionResult useOn(UseOnContext context) {
Level level = context.getLevel();
BlockState blockState = level.getBlockState(context.getClickedPos());
if (blockState.getBlock() instanceof mtr.block.BlockNode) {
if (context.isSecondaryUseActive()) {
if (level.isClientSide) {
BrushEditRailScreen.acquirePickInfoWhenUse();
return super.useOn(context);
if (this == mtr.Items.BRUSH.get()) {
Level level = context.getLevel();
BlockState blockState = level.getBlockState(context.getClickedPos());
if (blockState.getBlock() instanceof mtr.block.BlockNode) {
if (context.isSecondaryUseActive()) {
if (level.isClientSide) {
BrushEditRailScreen.acquirePickInfoWhenUse();
return super.useOn(context);
} else {
PacketScreen.sendScreenBlockS2C((ServerPlayer) context.getPlayer(), "brush_edit_rail", BlockPos.ZERO);
}
} else {
PacketScreen.sendScreenBlockS2C((ServerPlayer) context.getPlayer(), "brush_edit_rail", BlockPos.ZERO);
if (level.isClientSide) {
BrushEditRailScreen.acquirePickInfoWhenUse();
CompoundTag railBrushProp = context.getPlayer().getMainHandItem().getTagElement("NTERailBrush");
BrushEditRailScreen.applyBrushToPickedRail(railBrushProp);
} else {
return super.useOn(context);
}
}
return InteractionResult.SUCCESS;
} else {
if (level.isClientSide) {
CompoundTag railBrushProp = context.getPlayer().getMainHandItem().getTagElement("NTERailBrush");
BrushEditRailScreen.applyBrushToPickedRail(railBrushProp);
} else {
return super.useOn(context);
}
return super.useOn(context);
}
return InteractionResult.SUCCESS;
} else {
return super.useOn(context);
}
}
}
}

0 comments on commit aa88351

Please sign in to comment.