Skip to content

Commit

Permalink
actual finally good fix for the weird placement info thing
Browse files Browse the repository at this point in the history
since when was cursed type casting ever good?

also formatting
  • Loading branch information
rhysdh540 committed Nov 5, 2023
1 parent 82f6fcb commit 5db73c6
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.rdh.createunlimited.config;


import com.simibubi.create.foundation.config.ConfigBase;
import com.simibubi.create.foundation.config.ui.BaseConfigScreen;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.Entity;

import net.minecraftforge.common.ForgeConfigSpec.*;

Expand Down Expand Up @@ -61,17 +60,17 @@ public static void registerConfigCommand() {
LiteralArgumentBuilder<CommandSourceStack> category = null;

for (Field field : CUServer.class.getDeclaredFields()) {
//skip if not config value or string
// skip if not config value or string
if (!CValue.class.isAssignableFrom(field.getType())) continue;

String name = field.getName();

//change category if needed
// change category if needed
if (field.getType() == ConfigGroup.class) {
if (category != null) base.then(category);
category = literal(name);

//add description for category
// add description for category
assert base != null;
base.then(literal(field.getName()).executes(context -> {
context.message(CUServer.getComment(name));
Expand All @@ -91,12 +90,13 @@ public static void registerConfigCommand() {
continue;
}

ConfigValue<?> value = ((CValueAccessor<?, ?>) cValue).value;
// get config as forge config value
ConfigValue<?> value = ((CValueAccessor) cValue).value;

//get, description, reset
// get, description, reset
gdr(category, name, value);

//set for boolean
// set for boolean
if (value instanceof BooleanValue bValue)
setBoolean(category, name, bValue);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.rdh.createunlimited.mixin;


import com.simibubi.create.infrastructure.config.CTrains;

import dev.rdh.createunlimited.CreateUnlimited;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.rdh.createunlimited.mixin;


import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import com.simibubi.create.content.trains.entity.CarriageContraption;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.rdh.createunlimited.mixin;



import com.simibubi.create.content.decoration.copycat.CopycatBlock;

import dev.rdh.createunlimited.config.CUConfigs;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.rdh.createunlimited.mixin;



import com.simibubi.create.content.trains.station.StationBlockEntity;
import dev.rdh.createunlimited.config.CUConfigs;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.rdh.createunlimited.mixin;


import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.rdh.createunlimited.mixin;


import com.simibubi.create.AllTags;
import com.simibubi.create.content.trains.track.*;
import com.simibubi.create.foundation.utility.*;
Expand All @@ -10,7 +9,7 @@
import dev.rdh.createunlimited.Util;
import dev.rdh.createunlimited.config.CUConfigs;

import dev.rdh.createunlimited.duck.PlacementInfoDuck;
import dev.rdh.createunlimited.mixin.accessor.PlacementInfoAccessor;

import manifold.rt.api.NoBootstrap;

Expand Down Expand Up @@ -58,12 +57,12 @@ public static PlacementInfo tryConnect(Level level, Player player, BlockPos pos2
&& hoveringMaxed == maximiseTurn && lookAngle == hoveringAngle)
return cached;

PlacementInfoDuck info = (PlacementInfoDuck) new PlacementInfo(TrackMaterial.fromItem(stack.getItem()));
var info = (PlacementInfo & PlacementInfoAccessor) new PlacementInfo(TrackMaterial.fromItem(stack.getItem()));
hoveringMaxed = maximiseTurn;
hoveringAngle = lookAngle;
hoveringPos = pos2;
lastItem = stack;
cached = info.self();
cached = info;

ITrackBlock track = (ITrackBlock) state2.getBlock();
Pair<Vec3, Direction.AxisDirection> nearestTrackAxis = track.getNearestTrackAxis(level, pos2, state2, lookVec);
Expand Down Expand Up @@ -339,14 +338,14 @@ public static PlacementInfo tryConnect(Level level, Player player, BlockPos pos2
info.axis1 = axis1;
info.axis2 = axis2;

placeTracks(level, info.self(), state1, state2, targetPos1, targetPos2, true);
placeTracks(level, info, state1, state2, targetPos1, targetPos2, true);

ItemStack offhandItem = player.getOffhandItem()
.copy();
boolean shouldPave = offhandItem.getItem() instanceof BlockItem;
if (shouldPave) {
BlockItem paveItem = (BlockItem) offhandItem.getItem();
paveTracks(level, info.self(), paveItem, true);
paveTracks(level, info, paveItem, true);
info.hasRequiredPavement = true;
}

Expand Down Expand Up @@ -416,12 +415,12 @@ else if (j == inv.selected)
}

if (level.isClientSide())
return info.self();
return info;
if (shouldPave) {
BlockItem paveItem = (BlockItem) offhandItem.getItem();
paveTracks(level, info.self(), paveItem, false);
paveTracks(level, info, paveItem, false);
}
return placeTracks(level, info.self(), state1, state2, targetPos1, targetPos2, false);
return placeTracks(level, info, state1, state2, targetPos1, targetPos2, false);
}

@Invoker("paveTracks")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.rdh.createunlimited.mixin;


import com.simibubi.create.content.trains.entity.TrainRelocator;

import dev.rdh.createunlimited.config.CUConfigs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@NoBootstrap
@Mixin(value = CValue.class, remap = false)
public interface CValueAccessor<V, T extends ConfigValue<V>> {
public interface CValueAccessor {
@Accessor("value")
ConfigValue<V> getValue();
ConfigValue<?> getValue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,4 @@ public interface PlacementInfoAccessor {
BlockPos getPos2();
@Accessor("pos2")
void setPos2(BlockPos pos2);

@Accessor("requiredTracks")
int getRequiredTracks();
@Accessor("requiredTracks")
void setRequiredTracks(int requiredTracks);

@Accessor("hasRequiredTracks")
boolean hasRequiredTracks();
@Accessor("hasRequiredTracks")
void setHasRequiredTracks(boolean hasRequiredTracks);

@Accessor("requiredPavement")
int getRequiredPavement();
@Accessor("requiredPavement")
void setRequiredPavement(int requiredPavement);

@Accessor("hasRequiredPavement")
boolean hasRequiredPavement();
@Accessor("hasRequiredPavement")
void setHasRequiredPavement(boolean hasRequiredPavement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"CopycatBlockMixin",
"CTrainsMixin",
"ExtendoGripItemMixin",
"PlacementInfoMixin",
"StationBlockEntityMixin",
"SuperGlueSectionHandlerMixin",
"SuperGlueSelectionPacketMixin",
Expand Down

0 comments on commit 5db73c6

Please sign in to comment.