Skip to content

Commit

Permalink
update guilib
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Sep 21, 2023
1 parent e4a4c4d commit 9f25897
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
7 changes: 1 addition & 6 deletions src/main/java/com/troblecodings/signals/blocks/Signal.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public void destroy(final IWorld worldIn, final BlockPos pos, final BlockState s
}
}

@SuppressWarnings("unchecked")
public int getHeight(final Map<SEProperty, String> map) {
for (final PredicateProperty<Integer> property : this.prop.signalHeights) {
if (property.test(map))
Expand Down Expand Up @@ -227,7 +226,6 @@ public void renderOverlay(final RenderOverlayInfo info) {
this.renderOverlay(info, this.prop.customNameRenderHeight);
}

@SuppressWarnings("unchecked")
@OnlyIn(Dist.CLIENT)
public void renderScaleOverlay(final RenderOverlayInfo info, final float renderHeight) {
final Map<SEProperty, String> map = ClientSignalStateHandler
Expand Down Expand Up @@ -288,7 +286,6 @@ public void renderSingleScaleOverlay(final RenderOverlayInfo info) {
info.stack.popPose();
}

@SuppressWarnings("unchecked")
@OnlyIn(Dist.CLIENT)
public void renderOverlay(final RenderOverlayInfo info, final float renderHeight) {
float customRenderHeight = renderHeight;
Expand Down Expand Up @@ -439,7 +436,6 @@ public int getDirectSignal(final BlockState blockState, final IBlockReader block
return 0;
}

@SuppressWarnings("unchecked")
public void getUpdate(final World world, final BlockPos pos) {
if (this.prop.sounds.isEmpty())
return;
Expand All @@ -463,14 +459,13 @@ public void getUpdate(final World world, final BlockPos pos) {
}
}

@SuppressWarnings("unchecked")
public SoundProperty getSound(final Map<SEProperty, String> map) {
for (final SoundProperty property : this.prop.sounds) {
if (property.predicate.test(map)) {
return property;
}
}
return new SoundProperty();
return new SoundProperty(null, t -> true, -1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.troblecodings.guilib.ecs.GuiInfo;
import com.troblecodings.guilib.ecs.interfaces.UIClientSync;
import com.troblecodings.signals.OpenSignalsMain;
import com.troblecodings.signals.blocks.Signal;
import com.troblecodings.signals.core.PosIdentifier;
import com.troblecodings.signals.core.ReadBuffer;
import com.troblecodings.signals.core.SubsidiaryEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.troblecodings.signals.enums.ChangeableStage;
import com.troblecodings.signals.models.ModelInfoWrapper;

import net.minecraft.util.math.vector.Quaternion;

public class PreviewSideBar {

public static final float MODIFIER = 0.1f;
Expand All @@ -26,8 +28,9 @@ public PreviewSideBar(final float height) {
blockRenderEntity.setInheritHeight(true);
blockRenderEntity.setWidth(60);

// TODO Check if right
blockRenderEntity.add(new UIDrag((x, y) -> blockRender
.updateRotation(QuaternionWrapper.fromXYZ(0, (float) x * MODIFIER, 0))));
.updateRotation(new Quaternion(0, (float) x * MODIFIER, 0, false))));

blockRenderEntity.add(new UIScissor());
blockRenderEntity.add(new UIColor(GuiSignalBox.BACKGROUND_COLOR));
Expand Down Expand Up @@ -69,7 +72,7 @@ public void clear() {
}

public void update(final Signal signal) {
blockRender.setBlockState(new ModelInfoWrapper(signal, properties));
blockRender.setBlockState(signal.defaultBlockState(), new ModelInfoWrapper(properties));
}

}
10 changes: 5 additions & 5 deletions src/main/java/com/troblecodings/signals/guis/SidePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ public void helpUsageMode(final Map<BlockPos, SubsidiaryHolder> subsidiaries,

allNodes.forEach(currentNode -> {
final UILabel currentStatus = new UILabel(
I18n.format("info.usage.status") + " : "
+ I18n.format("info.usage.status.free"));
I18n.get("info.usage.status") + " : "
+ I18n.get("info.usage.status.free"));
currentStatus.setTextColor(new UIEntity().getBasicTextColor());
final UIEntity statusEntity = new UIEntity();
statusEntity.setInheritWidth(true);
Expand All @@ -259,15 +259,15 @@ public void helpUsageMode(final Map<BlockPos, SubsidiaryHolder> subsidiaries,
.getEntry(PathEntryType.PATHUSAGE);
if (pathUsage.isPresent()
&& !pathUsage.get().equals(EnumPathUsage.FREE)) {
currentStatus.setText(I18n.format("info.usage.status")
+ " : " + I18n.format("info.usage.status.blocked"));
currentStatus.setText(I18n.get("info.usage.status") + " : "
+ I18n.get("info.usage.status.blocked"));
canBeManuelChanged.set(false);
}
if (!entry.containsEntry(PathEntryType.OUTPUT))
return;
final String name = currentNode.getPoint().toString() + " - "
+ ClientNameHandler.getClientName(new NameStateInfo(
mc.world,
mc.level,
entry.getEntry(PathEntryType.OUTPUT).get()));
final UIEntity button = GuiElements.createButton(name, e1 -> {
gui.pop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
package com.troblecodings.signals.models;

import java.util.Map;

import com.troblecodings.core.interfaces.BlockModelDataWrapper;
import com.troblecodings.signals.SEProperty;

import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelDataMap.Builder;
import net.minecraftforge.client.model.data.ModelProperty;

public class ModelInfoWrapper implements IModelData {
public class ModelInfoWrapper implements BlockModelDataWrapper {

private final IModelData data;

public ModelInfoWrapper(final IModelData data) {
this.data = data;
}

public ModelInfoWrapper(final Map<SEProperty, String> states) {
final Builder builder = new ModelDataMap.Builder();
states.forEach((property, value) -> builder.withInitial(property, value));
this.data = builder.build();
}

@Override
public boolean hasProperty(final ModelProperty<?> prop) {
return data.hasProperty(prop);
Expand Down

0 comments on commit 9f25897

Please sign in to comment.