mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-04 23:53:01 +00:00
Merge branch 'mc-1.19.x' into mc-1.20.x
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.client.model;
|
||||
|
||||
import dan200.computercraft.shared.util.ConsList;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A model wrapper which applies a glint/foil to the original model.
|
||||
*/
|
||||
public final class FoiledModel extends BakedModelWrapper<BakedModel> {
|
||||
public FoiledModel(BakedModel model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData extraData, @Nullable RenderType renderType) {
|
||||
return renderType == RenderType.glint()
|
||||
? super.getQuads(state, side, rand, extraData, null)
|
||||
: super.getQuads(state, side, rand, extraData, renderType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RenderType> getRenderTypes(ItemStack itemStack, boolean fabulous) {
|
||||
return new ConsList<>(fabulous ? RenderType.glintDirect() : RenderType.glint(), super.getRenderTypes(itemStack, fabulous));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj || (obj instanceof FoiledModel other && originalModel.equals(other.originalModel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return originalModel.hashCode() ^ 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,22 +5,53 @@
|
||||
package dan200.computercraft.client.platform;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dan200.computercraft.client.model.FoiledModel;
|
||||
import dan200.computercraft.client.render.ModelRenderer;
|
||||
import dan200.computercraft.shared.network.NetworkMessage;
|
||||
import dan200.computercraft.shared.network.server.ServerNetworkContext;
|
||||
import dan200.computercraft.shared.platform.NetworkHandler;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
||||
@AutoService(dan200.computercraft.impl.client.ClientPlatformHelper.class)
|
||||
public class ClientPlatformHelperImpl implements ClientPlatformHelper {
|
||||
private static final RandomSource random = RandomSource.create(0);
|
||||
private static final Direction[] directions = Arrays.copyOf(Direction.values(), 7);
|
||||
|
||||
@Override
|
||||
public BakedModel getModel(ModelManager manager, ResourceLocation location) {
|
||||
return manager.getModel(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel createdFoiledModel(BakedModel model) {
|
||||
return new FoiledModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToServer(NetworkMessage<ServerNetworkContext> message) {
|
||||
NetworkHandler.sendToServer(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBakedModel(PoseStack transform, MultiBufferSource buffers, BakedModel model, int lightmapCoord, int overlayLight, @Nullable int[] tints) {
|
||||
for (var renderType : model.getRenderTypes(ItemStack.EMPTY, true)) {
|
||||
var buffer = buffers.getBuffer(renderType);
|
||||
for (var face : directions) {
|
||||
random.setSeed(42);
|
||||
var quads = model.getQuads(null, face, random, ModelData.EMPTY, renderType);
|
||||
ModelRenderer.renderQuads(transform, buffer, quads, lightmapCoord, overlayLight, tints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,6 @@
|
||||
"commands.computercraft.help.synopsis": "Provide help for a specific command",
|
||||
"commands.computercraft.queue.desc": "Send a computer_command event to a command computer, passing through the additional arguments. This is mostly designed for map makers, acting as a more computer-friendly version of /trigger. Any player can run the command, which would most likely be done through a text component's click event.",
|
||||
"commands.computercraft.queue.synopsis": "Send a computer_command event to a command computer",
|
||||
"commands.computercraft.reload.desc": "Reload the ComputerCraft config file",
|
||||
"commands.computercraft.reload.done": "Reloaded config",
|
||||
"commands.computercraft.reload.synopsis": "Reload the ComputerCraft config file",
|
||||
"commands.computercraft.shutdown.desc": "Shutdown the listed computers or all if none are specified. You can specify the computer's instance id (e.g. 123), computer id (e.g #123) or label (e.g. \"@My Computer\").",
|
||||
"commands.computercraft.shutdown.done": "Shutdown %s/%s computers",
|
||||
"commands.computercraft.shutdown.synopsis": "Shutdown computers remotely.",
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_advanced",
|
||||
"key": {"#": {"item": "minecraft:diamond_axe"}, "T": {"item": "computercraft:turtle_advanced"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_axe\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_advanced",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_axe\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_advanced",
|
||||
"key": {"#": {"item": "minecraft:diamond_hoe"}, "T": {"item": "computercraft:turtle_advanced"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_hoe\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_advanced",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_hoe\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_advanced",
|
||||
"key": {"#": {"item": "minecraft:diamond_pickaxe"}, "T": {"item": "computercraft:turtle_advanced"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_advanced",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_advanced",
|
||||
"key": {"#": {"item": "minecraft:diamond_shovel"}, "T": {"item": "computercraft:turtle_advanced"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_shovel\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_advanced",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_shovel\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_advanced",
|
||||
"key": {"#": {"item": "minecraft:diamond_sword"}, "T": {"item": "computercraft:turtle_advanced"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_sword\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_advanced",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_sword\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_normal",
|
||||
"key": {"#": {"item": "minecraft:diamond_axe"}, "T": {"item": "computercraft:turtle_normal"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_axe\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_normal",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_axe\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_normal",
|
||||
"key": {"#": {"item": "minecraft:diamond_hoe"}, "T": {"item": "computercraft:turtle_normal"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_hoe\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_normal",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_hoe\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_normal",
|
||||
"key": {"#": {"item": "minecraft:diamond_pickaxe"}, "T": {"item": "computercraft:turtle_normal"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_normal",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_normal",
|
||||
"key": {"#": {"item": "minecraft:diamond_shovel"}, "T": {"item": "computercraft:turtle_normal"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_shovel\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_normal",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_shovel\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"group": "computercraft:turtle_normal",
|
||||
"key": {"#": {"item": "minecraft:diamond_sword"}, "T": {"item": "computercraft:turtle_normal"}},
|
||||
"pattern": ["#T"],
|
||||
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_sword\"}"},
|
||||
"result": {
|
||||
"item": "computercraft:turtle_normal",
|
||||
"nbt": "{RightUpgrade:\"minecraft:diamond_sword\",RightUpgradeNbt:{Tag:{Damage:0}}}"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class ForgeConfigFile implements ConfigFile {
|
||||
|
||||
@Override
|
||||
public Stream<Entry> entries() {
|
||||
return entries.children();
|
||||
return entries.stream();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -68,7 +68,7 @@ public final class ForgeConfigFile implements ConfigFile {
|
||||
@Override
|
||||
public void pop() {
|
||||
var path = new ArrayList<>(groupStack);
|
||||
entries.setValue(path, new GroupImpl(path, entries.getChild(path)));
|
||||
entries.setValue(path, new GroupImpl(path));
|
||||
|
||||
builder.pop();
|
||||
super.pop();
|
||||
@@ -129,12 +129,10 @@ public final class ForgeConfigFile implements ConfigFile {
|
||||
|
||||
private static final class GroupImpl implements ConfigFile.Group {
|
||||
private final List<String> path;
|
||||
private final Trie<String, ConfigFile.Entry> entries;
|
||||
private @Nullable ForgeConfigSpec owner;
|
||||
|
||||
private GroupImpl(List<String> path, Trie<String, ConfigFile.Entry> entries) {
|
||||
private GroupImpl(List<String> path) {
|
||||
this.path = path;
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,11 +146,6 @@ public final class ForgeConfigFile implements ConfigFile {
|
||||
if (owner == null) throw new IllegalStateException("Config has not been built yet");
|
||||
return owner.getLevelComment(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entry> children() {
|
||||
return entries.children();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ValueImpl<T> implements ConfigFile.Value<T> {
|
||||
|
||||
@@ -365,9 +365,7 @@ public class PlatformHelperImpl implements PlatformHelper {
|
||||
) implements RegistryWrappers.RegistryWrapper<T> {
|
||||
@Override
|
||||
public int getId(T object) {
|
||||
var id = registry.getID(object);
|
||||
if (id == -1) throw new IllegalStateException(object + " was not registered in " + name);
|
||||
return id;
|
||||
return registry.getID(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -391,10 +389,13 @@ public class PlatformHelperImpl implements PlatformHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int id) {
|
||||
var object = registry.getValue(id);
|
||||
if (object == null) throw new IllegalStateException(id + " was not registered in " + name);
|
||||
return object;
|
||||
public @Nullable T byId(int id) {
|
||||
return registry.getValue(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return registry.getKeys().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user