Skip to content

Commit

Permalink
Remove extra code
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Aug 14, 2024
1 parent 021a60b commit 6e92a46
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 336 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.railwayteam.railways.registry.CRShapes;
import com.simibubi.create.content.equipment.extendoGrip.ExtendoGripItem;
import com.simibubi.create.content.equipment.wrench.IWrenchable;
import com.simibubi.create.foundation.block.IHaveBigOutline;
import com.simibubi.create.foundation.placement.IPlacementHelper;
import com.simibubi.create.foundation.placement.PlacementHelpers;
import com.simibubi.create.foundation.placement.PlacementOffset;
Expand Down Expand Up @@ -66,7 +67,7 @@
import java.util.Locale;
import java.util.function.Predicate;

public class BoilerBlock extends Block implements IWrenchable, IForceRenderingSodium, IHasCustomOutline {
public class BoilerBlock extends Block implements IWrenchable, IForceRenderingSodium, IHasCustomOutline, IHaveBigOutline {
public static final int placementHelperId = PlacementHelpers.register(new PlacementHelper());

public static final EnumProperty<Style> STYLE = EnumProperty.create("style", Style.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.railwayteam.railways.Railways;
import com.railwayteam.railways.content.smokestack.block.SmokeStackBlock;
import com.railwayteam.railways.util.ColorUtils;
import com.railwayteam.railways.util.IHaveCustomGoggleIcon;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
Expand All @@ -39,7 +38,7 @@

import java.util.List;

public class SmokeStackBlockEntity extends SmartBlockEntity implements IHaveGoggleInformation, IHaveCustomGoggleIcon {
public class SmokeStackBlockEntity extends SmartBlockEntity implements IHaveGoggleInformation {

public @Nullable DyeColor getColor() {
return color;
Expand Down Expand Up @@ -114,7 +113,7 @@ public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneak
}

@Override
public ItemStack railways$setGoggleIcon(boolean isPlayerSneaking) {
public ItemStack getIcon(boolean isPlayerSneaking) {
if (color != null)
return ColorUtils.getDyeColorDyeItem(color).getDefaultInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,63 +22,30 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.railwayteam.railways.registry.CRBogeyStyles;
import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock;
import com.simibubi.create.content.trains.bogey.AbstractBogeyBlockEntity;
import com.simibubi.create.content.trains.bogey.BogeySizes;
import com.simibubi.create.content.trains.bogey.BogeyStyle;
import com.simibubi.create.content.trains.track.ITrackBlock;
import com.simibubi.create.content.trains.track.TrackMaterial.TrackType;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Collection;
import java.util.List;
import java.util.Map;

@Mixin(value = AbstractBogeyBlock.class, remap = false)
public abstract class MixinAbstractBogeyBlock {
@Shadow protected abstract BlockState copyProperties(BlockState source, BlockState target);

@Shadow public abstract BlockState getStateOfSize(AbstractBogeyBlockEntity sbte, BogeySizes.BogeySize size);

// fixme this is a Create bug, file a report (styles not placing the correct block)
// Has been merged, awaiting release
@Inject(method = "use",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;displayClientMessage(Lnet/minecraft/network/chat/Component;Z)V", remap = true, ordinal = 0),
locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true, remap = true)
private void placeCorrectedBlock(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir, ItemStack stack,
BlockEntity be, AbstractBogeyBlockEntity sbbe, BogeyStyle currentStyle,
BogeySizes.BogeySize size, BogeyStyle style) {
if (state.getBlock() != style.getBlockOfSize(size)) {
CompoundTag oldData = sbbe.getBogeyData();
level.setBlock(pos, copyProperties(state, getStateOfSize(sbbe, size)), 3);
BlockEntity newBlockEntity = level.getBlockEntity(pos);
if (!(newBlockEntity instanceof AbstractBogeyBlockEntity newBlockEntity1)) {
cir.setReturnValue(InteractionResult.FAIL);
return;
}
newBlockEntity1.setBogeyData(oldData);
}
}

@Unique
private final ThreadLocal<TrackType> railways$trackType = new ThreadLocal<>();
@Unique private final ThreadLocal<TrackType> railways$trackType = new ThreadLocal<>();

@Inject(method = "getNextStyle(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lcom/simibubi/create/content/trains/bogey/BogeyStyle;", at = @At("HEAD"), remap = true)
private void storeSupportType(Level level, BlockPos pos, CallbackInfoReturnable<BogeyStyle> cir) {
Expand Down Expand Up @@ -129,7 +96,7 @@ private Object wrapCycleWithFallback(List<Object> list, Object style, Operation<
try {
return original.call(list, style);
} catch (IllegalArgumentException e) {
return list.get(0);
return list.getFirst();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,29 @@
package com.railwayteam.railways.mixin;

import com.railwayteam.railways.content.roller_extensions.TrackReplacePaver;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.contraptions.actors.roller.PaveTask;
import com.simibubi.create.content.contraptions.actors.roller.RollerMovementBehaviour;
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
import com.simibubi.create.content.trains.track.ITrackBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import javax.annotation.Nullable;

@Mixin(value = RollerMovementBehaviour.class, remap = false)
public abstract class MixinRollerMovementBehaviour {
@Shadow protected abstract BlockState getStateToPaveWithAsSlab(MovementContext context);

@Shadow protected abstract BlockState getStateToPaveWith(MovementContext context);


@Shadow @Nullable protected abstract PaveTask createHeightProfileForTracks(MovementContext context);

// fixme this is a Create bug
// https://github.com/Creators-of-Create/Create/pull/6272 Remove this mixin whenever this is merged
// Has been merged, awaiting release
@Deprecated
@Inject(method = "canBreak", at = @At("RETURN"), cancellable = true)
private void noBreakingTracks(Level world, BlockPos breakingPos, BlockState state, CallbackInfoReturnable<Boolean> cir) {
if (AllTags.AllBlockTags.TRACKS.matches(state))
cir.setReturnValue(false);
}

@Inject(method = "triggerPaver", at = @At("HEAD"), cancellable = true)
private void skipTracksAndPaveTracks(MovementContext context, BlockPos pos, CallbackInfo ci) {
BlockState stateToPaveWith = getStateToPaveWith(context);
BlockState stateToPaveWithAsSlab = getStateToPaveWithAsSlab(context);
int mode = context.blockEntityData.getInt("ScrollValue");
if (mode == 3) { // TRACK_REPLACE
ci.cancel();
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion common/src/main/resources/railways-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
"client.MixinCarriageSounds",
"client.MixinCurvedTrackInteraction",
"client.MixinDebugRenderer",
"client.MixinGameRenderer",
"client.MixinGlobalRailwayManager",
"client.MixinItemModelShaper",
"client.MixinLevelRenderer",
Expand Down
Loading

0 comments on commit 6e92a46

Please sign in to comment.