Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08bf927526 | ||
|
|
eab2ef67b7 | ||
|
|
5342c4daa5 | ||
|
|
685352762a | ||
|
|
0d901782c3 | ||
|
|
0cc6233d2c | ||
|
|
10a8845805 | ||
|
|
d98332f614 | ||
|
|
dd30dc26b8 | ||
|
|
22077c032c | ||
|
|
6097b048a4 | ||
|
|
df553315a7 | ||
|
|
1905c9a655 | ||
|
|
38ae4d8adb | ||
|
|
9a4569b529 | ||
|
|
3ee972b4d0 | ||
|
|
5deb39e0c6 |
22
.github/ISSUE_TEMPLATE/blacklist-request.md
vendored
22
.github/ISSUE_TEMPLATE/blacklist-request.md
vendored
|
|
@ -1,22 +0,0 @@
|
|||
---
|
||||
name: Blacklist Request
|
||||
about: Have a block / entity that shouldn't be picked up by Carry On? Report it here.
|
||||
title: "[Blacklist]"
|
||||
labels: Blacklist
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the problem**
|
||||
What block / entity is causing issues? What problems occur with placement / pickup?
|
||||
|
||||
**ID's to Blacklist**
|
||||
List of block identifiers (namespace:name) to blacklist. You can find identifiers by activating F3 and moving your crosshair over the block
|
||||
-
|
||||
-
|
||||
...
|
||||
|
||||
**Game Information (please complete the following information):**
|
||||
- Minecraft Version:
|
||||
- Mod Loader:
|
||||
- Carry On Version:
|
||||
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report about a crash or otherwise buggy behavior
|
||||
title: "[Bug]"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1.
|
||||
2.
|
||||
...
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Game Information (please complete the following information):**
|
||||
- Minecraft Version:
|
||||
- Mod Loader:
|
||||
- Carry On Version:
|
||||
|
||||
**Additional context, logs**
|
||||
Add any other context about the problem here. Also include logs if available
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for Carry On
|
||||
title: "[Feature Request]"
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -22,6 +22,3 @@ build
|
|||
eclipse
|
||||
run
|
||||
runs
|
||||
|
||||
# vscode
|
||||
.vscode/*
|
||||
|
|
@ -1,51 +1,56 @@
|
|||
plugins {
|
||||
id 'multiloader-common'
|
||||
id 'net.neoforged.moddev'
|
||||
id 'idea'
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
|
||||
base {
|
||||
archivesName = "${mod_id}-common-${minecraft_version}"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version(minecraft_version)
|
||||
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
|
||||
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Shedaniel"
|
||||
url "https://maven.shedaniel.me/"
|
||||
}
|
||||
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
neoForge {
|
||||
neoFormVersion = neo_form_version
|
||||
// Automatically enable AccessTransformers if the file exists
|
||||
def at = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
parchment {
|
||||
minecraftVersion = parchment_game_version
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||
// fabric and neoforge both bundle mixinextras, so it is safe to use it in common
|
||||
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
|
||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
||||
implementation("io.github.llamalad7:mixinextras-common:${mixinextras_version}")
|
||||
annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}")
|
||||
|
||||
compileOnly("me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}")
|
||||
}
|
||||
|
||||
configurations {
|
||||
commonJava {
|
||||
canBeResolved = false
|
||||
canBeConsumed = true
|
||||
}
|
||||
commonResources {
|
||||
canBeResolved = false
|
||||
canBeConsumed = true
|
||||
processResources {
|
||||
|
||||
def buildProps = project.properties.clone()
|
||||
|
||||
filesMatching(['pack.mcmeta']) {
|
||||
|
||||
expand buildProps
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
commonJava sourceSets.main.java.sourceDirectories.singleFile
|
||||
commonResources sourceSets.main.resources.sourceDirectories.singleFile
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
groupId project.group
|
||||
artifactId base.archivesName .get()
|
||||
version project.version
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,8 @@ import net.minecraft.core.RegistryAccess;
|
|||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -39,6 +41,7 @@ import tschipp.carryon.common.command.CommandCarryOn;
|
|||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingOtherPlayerPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundStartRidingPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
|
@ -89,6 +92,14 @@ public class CarryOnCommon
|
|||
ClientboundStartRidingOtherPlayerPacket::handle,
|
||||
args
|
||||
);
|
||||
|
||||
Services.PLATFORM.registerClientboundPacket(
|
||||
ClientboundSyncCarryDataPacket.TYPE,
|
||||
ClientboundSyncCarryDataPacket.class,
|
||||
ClientboundSyncCarryDataPacket.CODEC,
|
||||
ClientboundSyncCarryDataPacket::handle,
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
public static void registerConfig()
|
||||
|
|
@ -108,7 +119,7 @@ public class CarryOnCommon
|
|||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying())
|
||||
{
|
||||
// Dumb Fix to sync Carry Data after a respawn with KeepInventory, because we can't sync in the first tick.
|
||||
//Dirty Hack to sync carry data 1 tick after respawning
|
||||
if(player.tickCount == 1)
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
|
||||
|
|
@ -116,11 +127,16 @@ public class CarryOnCommon
|
|||
{
|
||||
String cmd = carry.getActiveScript().get().scriptEffects().commandLoop();
|
||||
if(!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
if (!Constants.COMMON_CONFIG.settings.slownessInCreative && player.isCreative())
|
||||
return;
|
||||
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(carry, player.level()), false, false));
|
||||
|
||||
Inventory inv = player.getInventory();
|
||||
inv.setSelectedSlot(carry.getSelected());
|
||||
inv.selected = carry.getSelected();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +170,7 @@ public class CarryOnCommon
|
|||
|
||||
public static void onPlayerAttacked(Player player)
|
||||
{
|
||||
if (Constants.COMMON_CONFIG.settings.dropCarriedWhenHit && !player.level().isClientSide())
|
||||
if (Constants.COMMON_CONFIG.settings.dropCarriedWhenHit && !player.level().isClientSide)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (carry.isCarrying())
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ public class CarryOnCommonClient
|
|||
Player player = mc.player;
|
||||
if(player != null) {
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if ((CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown())) && !carry.isKeyPressed()) {
|
||||
if ((CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() || checkMouse())) && !carry.isKeyPressed()) {
|
||||
CarryOnKeybinds.onCarryKey(true);
|
||||
carry.setKeyPressed(true);
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
} else if (!(CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() ) ) && carry.isKeyPressed()) {
|
||||
} else if (!(CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() || checkMouse()) ) && carry.isKeyPressed()) {
|
||||
CarryOnKeybinds.onCarryKey(false);
|
||||
carry.setKeyPressed(false);
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
|
|
@ -46,16 +46,20 @@ public class CarryOnCommonClient
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean checkMouse()
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
return (CarryOnKeybinds.carryKey.matchesMouse(0) && mc.mouseHandler.isLeftPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(1) && mc.mouseHandler.isRightPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(3) && mc.mouseHandler.isMiddlePressed());
|
||||
}
|
||||
|
||||
public static void onCarryClientTick() {
|
||||
public static void onCarryClientTick()
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
if(player != null) {
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (carry.isCarrying()) {
|
||||
int wantedSlot = carry.getSelected();
|
||||
if (player.getInventory().getSelectedSlot() != wantedSlot) {
|
||||
player.getInventory().setSelectedSlot(wantedSlot);
|
||||
}
|
||||
if(carry.isCarrying())
|
||||
{
|
||||
player.getInventory().selected = carry.getSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -64,4 +68,4 @@ public class CarryOnCommonClient
|
|||
{
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
package tschipp.carryon;
|
||||
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tschipp.carryon.common.config.CarryConfig;
|
||||
|
|
@ -34,10 +34,10 @@ public class Constants {
|
|||
public static final CarryConfig.Common COMMON_CONFIG = new CarryConfig.Common();
|
||||
public static final CarryConfig.Client CLIENT_CONFIG = new CarryConfig.Client();
|
||||
|
||||
public static final Identifier PACKET_ID_KEY_PRESSED = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "key_pressed");
|
||||
public static final Identifier PACKET_ID_START_RIDING = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "start_riding");
|
||||
public static final Identifier PACKET_ID_SYNC_SCRIPTS = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "sync_scripts");
|
||||
public static final Identifier PACKET_ID_START_RIDING_OTHER = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "start_riding_other");
|
||||
public static final Identifier PACKET_ID_SYNC_CARRY_ON_DATA = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "sync_carry_data");
|
||||
public static final ResourceLocation PACKET_ID_KEY_PRESSED = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "key_pressed");
|
||||
public static final ResourceLocation PACKET_ID_START_RIDING = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "start_riding");
|
||||
public static final ResourceLocation PACKET_ID_SYNC_SCRIPTS = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "sync_scripts");
|
||||
public static final ResourceLocation PACKET_ID_START_RIDING_OTHER = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "start_riding_other");
|
||||
public static final ResourceLocation PACKET_ID_SYNC_CARRY_ON_DATA = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "sync_carry_data");
|
||||
|
||||
}
|
||||
|
|
@ -22,8 +22,6 @@ package tschipp.carryon.client.keybinds;
|
|||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.KeyMapping.Category;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.networking.serverbound.ServerboundCarryKeyPressedPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
|
@ -36,9 +34,10 @@ public class CarryOnKeybinds
|
|||
|
||||
public static void registerKeybinds(Consumer<KeyMapping> registrar)
|
||||
{
|
||||
Category category = Category.register(Identifier.fromNamespaceAndPath(Constants.MOD_ID,"key.carry.category"));
|
||||
|
||||
carryKey = new KeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, category);
|
||||
if(Services.PLATFORM.isModLoaded("amecsapi"))
|
||||
carryKey = new ConflictFreeKeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, "key.carry.category");
|
||||
else
|
||||
carryKey = new ConflictFreeKeyMapping("key.carry.desc", Services.PLATFORM.getPlatformName().equals("Forge") ? InputConstants.KEY_LSHIFT : InputConstants.UNKNOWN.getValue(), "key.carry.category");
|
||||
|
||||
registrar.accept(carryKey);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* GNU Lesser General Public License v3
|
||||
* Copyright (C) 2024 Tschipp
|
||||
* mrtschipp@gmail.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package tschipp.carryon.client.keybinds;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants.Type;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
|
||||
public class ConflictFreeKeyMapping extends KeyMapping
|
||||
{
|
||||
public ConflictFreeKeyMapping(String $$0, int $$1, String $$2)
|
||||
{
|
||||
super($$0, $$1, $$2);
|
||||
}
|
||||
|
||||
public ConflictFreeKeyMapping(String $$0, Type $$1, int $$2, String $$3)
|
||||
{
|
||||
super($$0, $$1, $$2, $$3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean same(KeyMapping $$0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,13 +39,22 @@ import tschipp.carryon.common.scripting.Matchables.NBTCondition;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModelOverride {
|
||||
public class ModelOverride
|
||||
{
|
||||
//public static Codec<ModelOverride> CODEC = Codec.STRING.comapFlatMap(ModelOverride::of, override -> override.raw);
|
||||
|
||||
private String raw;
|
||||
private BlockResult parsedBlock;
|
||||
private Type type;
|
||||
private Either<ItemResult, BlockResult> parsedRHS;
|
||||
private Either<ItemStack, BlockState> renderObject;
|
||||
|
||||
private ModelOverride(String raw, BlockResult parsedBlock, Type type, Either<ItemResult, BlockResult> parsedRHS)
|
||||
{
|
||||
this.raw = raw;
|
||||
this.parsedBlock = parsedBlock;
|
||||
this.type = type;
|
||||
this.parsedRHS = parsedRHS;
|
||||
|
||||
parsedRHS.ifLeft(res -> {
|
||||
ItemStack stack = new ItemStack(res.item());
|
||||
|
|
@ -71,7 +80,7 @@ public class ModelOverride {
|
|||
BlockResult res;
|
||||
|
||||
try {
|
||||
res = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK, from, true);
|
||||
res = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), from, true);
|
||||
} catch (Exception e) {
|
||||
return DataResult.error(() -> "Error while parsing " + from + ":" + e.getMessage());
|
||||
}
|
||||
|
|
@ -91,7 +100,7 @@ public class ModelOverride {
|
|||
if(type == Type.ITEM)
|
||||
either = Either.left(new ItemParser(provider).parse(new StringReader(to)));
|
||||
else
|
||||
either = Either.right(BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK, to, true));
|
||||
either = Either.right(BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), to, true));
|
||||
}catch (CommandSyntaxException e) {
|
||||
String finalTo = to;
|
||||
return DataResult.error(() -> "Error while parsing " + finalTo + ":" + e.getMessage());
|
||||
|
|
|
|||
|
|
@ -20,42 +20,62 @@
|
|||
|
||||
package tschipp.carryon.client.render;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.ByteBufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
||||
import net.minecraft.client.renderer.state.CameraRenderState;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptRender;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.SequencedMap;
|
||||
|
||||
public class CarriedObjectRender
|
||||
{
|
||||
public static boolean draw(Player player, PoseStack matrix, int light, float partialTicks,SubmitNodeCollector nodeCollector, boolean firstPerson)
|
||||
|
||||
private static SequencedMap<RenderType, ByteBufferBuilder> builders = new LinkedHashMap<>(Map.of(
|
||||
RenderType.glint(), new ByteBufferBuilder(RenderType.glint().bufferSize()),
|
||||
RenderType.armorEntityGlint(), new ByteBufferBuilder(RenderType.armorEntityGlint().bufferSize()),
|
||||
RenderType.glintTranslucent(), new ByteBufferBuilder(RenderType.glintTranslucent().bufferSize()),
|
||||
RenderType.entityGlint(), new ByteBufferBuilder(RenderType.entityGlint().bufferSize()),
|
||||
RenderType.entityGlintDirect(), new ByteBufferBuilder(RenderType.entityGlintDirect().bufferSize())
|
||||
));
|
||||
|
||||
public static boolean drawFirstPerson(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks)
|
||||
{
|
||||
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod") || player == null)
|
||||
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod"))
|
||||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
try {
|
||||
if (carry.isCarrying(CarryType.BLOCK))
|
||||
drawBlock(player, matrix, light, CarryRenderHelper.getRenderState(player), nodeCollector, firstPerson, partialTicks);
|
||||
drawFirstPersonBlock(player, buffer, matrix, light, CarryRenderHelper.getRenderState(player));
|
||||
else if (carry.isCarrying(CarryType.ENTITY))
|
||||
drawEntity(player, matrix, light, partialTicks, nodeCollector, firstPerson);
|
||||
drawFirstPersonEntity(player, buffer, matrix, light, partialTicks);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -75,59 +95,190 @@ public class CarriedObjectRender
|
|||
return carry.isCarrying();
|
||||
}
|
||||
|
||||
private static void drawBlock(Player player, PoseStack matrix, int light, BlockState state, SubmitNodeCollector nodeCollector, boolean firstPerson, float partialTicks)
|
||||
private static void drawFirstPersonBlock(Player player, MultiBufferSource buffer, PoseStack matrix, int light, BlockState state)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
ItemStackRenderState renderState = new ItemStackRenderState();
|
||||
var layer = renderState.newLayer();
|
||||
layer.setRenderType(RenderTypes.glint());
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.scale(2.5f, 2.5f, 2.5f);
|
||||
matrix.translate(0, -0.5, -1);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableCull();
|
||||
|
||||
PoseStack renderPose = CarryRenderHelper.setupBlockTransformations(player, matrix, carry, firstPerson);
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
ItemStack renderStack = CarryRenderHelper.getRenderItemStack(player);
|
||||
Minecraft.getInstance().getItemModelResolver().updateForTopItem(renderState, renderStack, ItemDisplayContext.NONE, player.level(), null, 0);
|
||||
renderState.submit(renderPose, nodeCollector, light, OverlayTexture.NO_OVERLAY, 0);
|
||||
if (Constants.CLIENT_CONFIG.facePlayer != CarryRenderHelper.isChest(state.getBlock())) {
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(8));
|
||||
} else {
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(8));
|
||||
}
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
CarryRenderHelper.performScriptTransformation(matrix, carry.getActiveScript().get());
|
||||
|
||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
ItemStack stack = new ItemStack(state.getBlock().asItem());
|
||||
BakedModel model = CarryRenderHelper.getRenderBlock(player);
|
||||
CarryRenderHelper.renderBakedModel(stack, matrix, buffer, light, model);
|
||||
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.disableBlend();
|
||||
matrix.popPose();
|
||||
}
|
||||
|
||||
private static void drawEntity(Player player, PoseStack matrix, int light, float partialTicks,SubmitNodeCollector nodeCollector, boolean firstPerson) {
|
||||
private static void drawFirstPersonEntity(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks) {
|
||||
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
|
||||
Entity entity = CarryRenderHelper.getRenderEntity(player);
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity != null)
|
||||
{
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialTicks);
|
||||
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialTicks);
|
||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||
entity.xRotO = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
|
||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||
entity.xRotO = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.pushPose();
|
||||
matrix.scale(0.8f, 0.8f, 0.8f);
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrix.translate(0.0, -height - .1, width + 0.1);
|
||||
|
||||
CarryRenderHelper.setupEntityTransformations(player, matrix, carry, firstPerson);
|
||||
manager.setRenderShadow(false);
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
((LivingEntity) entity).hurtTime = 0;
|
||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
||||
if(res.isPresent())
|
||||
{
|
||||
CarryOnScript script = res.get();
|
||||
CarryRenderHelper.performScriptTransformation(matrix, script);
|
||||
}
|
||||
|
||||
try {
|
||||
EntityRenderState renderState = manager.extractEntity(entity, 0);
|
||||
renderState.shadowPieces.clear();
|
||||
renderState.lightCoords = light;
|
||||
manager.submit(renderState, new CameraRenderState(), 0, 0, 0, matrix, nodeCollector);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
if (entity instanceof LivingEntity)
|
||||
((LivingEntity) entity).hurtTime = 0;
|
||||
|
||||
matrix.popPose();
|
||||
if(!firstPerson)
|
||||
try {
|
||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
manager.setRenderShadow(true);
|
||||
matrix.popPose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the third person view of entities and blocks
|
||||
* @param partialticks
|
||||
* @param mat
|
||||
*/
|
||||
public static void drawThirdPerson(float partialticks, Matrix4f mat) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Level level = mc.level;
|
||||
int light = 0;
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
|
||||
|
||||
PoseStack matrix = new PoseStack();
|
||||
matrix.mulPose(mat);
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
BufferSource buffer = MultiBufferSource.immediateWithBuffers(builders, builders.get(RenderType.glint()));
|
||||
|
||||
for (Player player : level.players())
|
||||
{
|
||||
try {
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
if (perspective == 0 && player == mc.player && !(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod") || Services.PLATFORM.isModLoaded("realcamera")))
|
||||
continue;
|
||||
|
||||
light = manager.getPackedLightCoords(player, partialticks);
|
||||
|
||||
if (carry.isCarrying(CarryType.BLOCK)) {
|
||||
BlockState state = CarryRenderHelper.getRenderState(player);
|
||||
|
||||
CarryRenderHelper.applyBlockTransformations(player, partialticks, matrix, state.getBlock());
|
||||
|
||||
ItemStack tileItem = new ItemStack(state.getBlock().asItem());
|
||||
BakedModel model = CarryRenderHelper.getRenderBlock(player);
|
||||
|
||||
//ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, level, player) : tileItem.isEmpty() ? mc.getBlockRenderer().getBlockModel(state) : mc.getItemRenderer().getModel(tileItem, level, player, 0);
|
||||
//
|
||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
||||
if (res.isPresent()) {
|
||||
CarryOnScript script = res.get();
|
||||
CarryRenderHelper.performScriptTransformation(matrix, script);
|
||||
}
|
||||
|
||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
||||
RenderSystem.enableCull();
|
||||
|
||||
PoseStack.Pose p = matrix.last();
|
||||
PoseStack copy = new PoseStack();
|
||||
copy.mulPose(p.pose());
|
||||
matrix.popPose();
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
CarryRenderHelper.renderBakedModel(tileItem, copy, buffer, light, model);
|
||||
|
||||
matrix.popPose();
|
||||
} else if (carry.isCarrying(CarryType.ENTITY)) {
|
||||
Entity entity = CarryRenderHelper.getRenderEntity(player);
|
||||
|
||||
if (entity != null) {
|
||||
CarryRenderHelper.applyEntityTransformations(player, partialticks, matrix, entity);
|
||||
|
||||
manager.setRenderShadow(false);
|
||||
|
||||
Optional<CarryOnScript> res = carry.getActiveScript();
|
||||
if (res.isPresent()) {
|
||||
CarryOnScript script = res.get();
|
||||
CarryRenderHelper.performScriptTransformation(matrix, script);
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity le)
|
||||
le.hurtTime = 0;
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||
matrix.popPose();
|
||||
manager.setRenderShadow(true);
|
||||
matrix.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
buffer.endLastBatch();
|
||||
|
||||
buffer.endBatch(RenderType.entitySolid(TextureAtlas.LOCATION_BLOCKS));
|
||||
buffer.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS));
|
||||
buffer.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS));
|
||||
buffer.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS));
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,20 +23,23 @@ package tschipp.carryon.client.render;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.joml.Quaternionf;
|
||||
|
|
@ -74,60 +77,91 @@ public class CarryRenderHelper
|
|||
return Axis.YP.rotationDegrees(getExactBodyRotationDegrees(entity, partialticks));
|
||||
}
|
||||
|
||||
public static void applyGeneralTransformations(Player player, PoseStack matrix)
|
||||
public static void applyGeneralTransformations(Player player, float partialticks, PoseStack matrix)
|
||||
{
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
Quaternionf playerrot = CarryRenderHelper.getExactBodyRotation(player, partialticks);
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
Vec3 offset = playerpos.subtract(cameraPos);
|
||||
Pose pose = player.getPose();
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.translate(offset.x, offset.y, offset.z);
|
||||
|
||||
if (perspective == 2)
|
||||
playerrot.mul(Axis.YP.rotationDegrees(180));
|
||||
matrix.mulPose(playerrot);
|
||||
|
||||
matrix.pushPose();
|
||||
matrix.scale(0.6f, 0.6f, 0.6f);
|
||||
|
||||
matrix.translate(0, 0, -1.35);
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, 0, -1.35);
|
||||
|
||||
if (doSneakCheck(player))
|
||||
{
|
||||
matrix.translate(0, -0.4, 0);
|
||||
}
|
||||
|
||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
if (pose == Pose.SWIMMING)
|
||||
{
|
||||
matrix.translate(0, 0, 2.5);
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(90));
|
||||
}
|
||||
|
||||
matrix.translate(0, -0.5, 0.65);
|
||||
}
|
||||
|
||||
public static PoseStack setupBlockTransformations(Player player, PoseStack matrix, CarryOnData carry, boolean firstPerson) {
|
||||
if (firstPerson) {
|
||||
matrix.scale(2.5f, 2.5f, 2.5f);
|
||||
matrix.translate(0, -0.5, -1);
|
||||
|
||||
if (Constants.CLIENT_CONFIG.facePlayer != CarryRenderHelper.isChest(carry.getBlock().getBlock())) {
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(8));
|
||||
} else {
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(8));
|
||||
float f = player.getSwimAmount(partialticks);
|
||||
float f3 = player.isInWater() ? -90.0F - player.xRotO : -90.0F;
|
||||
float f4 = Mth.lerp(f, 0.0F, f3);
|
||||
if (perspective == 2)
|
||||
{
|
||||
matrix.translate(0, 0, 1.35);
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(f4));
|
||||
}
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
else
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(f4));
|
||||
|
||||
return matrix;
|
||||
} else {
|
||||
CarryRenderHelper.applyBlockTransformations(player, matrix, carry.getBlock().getBlock());
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
|
||||
PoseStack.Pose p = matrix.last();
|
||||
PoseStack copy = new PoseStack();
|
||||
copy.mulPose(p.pose());
|
||||
matrix.popPose();
|
||||
|
||||
return copy;
|
||||
matrix.translate(0, -1.5, -1.848);
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, 0, 2.38);
|
||||
}
|
||||
|
||||
if (pose == Pose.FALL_FLYING)
|
||||
{
|
||||
float f1 = player.getFallFlyingTicks() + partialticks;
|
||||
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
||||
if (!player.isAutoSpinAttack())
|
||||
{
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, 0, 1.35);
|
||||
|
||||
if (perspective == 2)
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||
else
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||
}
|
||||
|
||||
Vec3 viewVector = player.getViewVector(partialticks);
|
||||
Vec3 deltaMovement = player.getDeltaMovement();
|
||||
double d0 = deltaMovement.horizontalDistanceSqr();
|
||||
double d1 = deltaMovement.horizontalDistanceSqr();
|
||||
if (d0 > 0.0D && d1 > 0.0D)
|
||||
{
|
||||
double d2 = (deltaMovement.x * viewVector.x + deltaMovement.z * viewVector.z) / (Math.sqrt(d0) * Math.sqrt(d1));
|
||||
double d3 = deltaMovement.x * viewVector.z - deltaMovement.z * viewVector.x;
|
||||
|
||||
matrix.mulPose(Axis.YP.rotation((float) (Math.signum(d3) * Math.acos(d2))));
|
||||
}
|
||||
|
||||
if (perspective != 2)
|
||||
matrix.translate(0, 0, -1.35);
|
||||
matrix.translate(0, -0.2, 0);
|
||||
}
|
||||
|
||||
matrix.translate(0, 1.6, 0.65);
|
||||
}
|
||||
|
||||
public static void applyBlockTransformations(Player player, PoseStack matrix, Block block)
|
||||
public static void applyBlockTransformations(Player player, float partialticks, PoseStack matrix, Block block)
|
||||
{
|
||||
matrix.mulPose(Axis.ZN.rotationDegrees(180));
|
||||
applyGeneralTransformations(player, matrix);
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
|
||||
applyGeneralTransformations(player, partialticks, matrix);
|
||||
|
||||
if (Constants.CLIENT_CONFIG.facePlayer != CarryRenderHelper.isChest(block))
|
||||
{
|
||||
|
|
@ -136,71 +170,60 @@ public class CarryRenderHelper
|
|||
// matrix.translate(0, 0, -0.4);
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
}
|
||||
// if(perspective == 1)
|
||||
// {
|
||||
// matrix.pushPose();
|
||||
// //matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
// matrix.popPose();
|
||||
// }
|
||||
|
||||
//else if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
|
||||
// matrix.translate(0, 0, 0.4);
|
||||
//matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
|
||||
|
||||
|
||||
float height = getRenderHeight(player);
|
||||
float offset = (height - 1f) / 1.2f;
|
||||
matrix.translate(0, -offset, 0);
|
||||
}
|
||||
|
||||
public static void setupEntityTransformations(Player player, PoseStack matrix, CarryOnData carry, boolean firstPerson) {
|
||||
|
||||
Entity entity = carry.getEntity(player.level());
|
||||
|
||||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
|
||||
if(firstPerson) {
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
|
||||
matrix.scale(0.8f, 0.8f, 0.8f);
|
||||
matrix.translate(0.0, -height - .2, width * 1.3 + 0.1);
|
||||
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
|
||||
if(Constants.CLIENT_CONFIG.rotateEntitiesSideways)
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(90));
|
||||
}
|
||||
else {
|
||||
applyEntityTransformations(player, matrix, entity);
|
||||
|
||||
carry.getActiveScript().ifPresent(script -> CarryRenderHelper.performScriptTransformation(matrix, script));
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyEntityTransformations(Player player, PoseStack matrix, Entity entity)
|
||||
public static void applyEntityTransformations(Player player, float partialticks, PoseStack matrix, Entity entity)
|
||||
{
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
Pose pose = player.getPose();
|
||||
|
||||
applyGeneralTransformations(player, matrix);
|
||||
applyGeneralTransformations(player, partialticks, matrix);
|
||||
|
||||
matrix.mulPose(Axis.XP.rotationDegrees(180));
|
||||
|
||||
matrix.translate(0, -3.1, -0.65);
|
||||
if (perspective == 2)
|
||||
matrix.translate(0, -1.6, 0.65);
|
||||
else
|
||||
matrix.translate(0, -1.6, -0.65);
|
||||
matrix.scale(1.666f, 1.666f, 1.666f);
|
||||
|
||||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
float multiplier = Math.min(9.9f, height * width) ;
|
||||
float multiplier = height * width;
|
||||
entity.yo = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
entity.xo = 0.0f;
|
||||
entity.xRotO = 0.0f;
|
||||
|
||||
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
||||
matrix.translate(0.0, height / 2 + -(height / 4) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||
if (perspective == 2)
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(180));
|
||||
|
||||
if(doSneakCheck(player))
|
||||
matrix.translate(0, -0.4, 0);
|
||||
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
||||
matrix.translate(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||
|
||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
{
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(180));
|
||||
matrix.translate(0, 0.2 * height - 2, -0.5);
|
||||
}
|
||||
matrix.mulPose(Axis.XN.rotationDegrees(90));
|
||||
matrix.translate(0, -0.2 * height, 0);
|
||||
|
||||
if(Constants.CLIENT_CONFIG.rotateEntitiesSideways)
|
||||
matrix.mulPose(Axis.YP.rotationDegrees(90));
|
||||
if (pose == Pose.FALL_FLYING)
|
||||
matrix.translate(0, 0, 0.2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -225,64 +248,18 @@ public class CarryRenderHelper
|
|||
matrix.scale((float) scale.x, (float) scale.y, (float) scale.z);
|
||||
}
|
||||
|
||||
/*
|
||||
@Deprecated
|
||||
|
||||
|
||||
public static void renderBakedModel(ItemStack stack, PoseStack matrix, MultiBufferSource buffer, int light, BakedModel model)
|
||||
{
|
||||
ItemStackRenderState state = new ItemStackRenderState();
|
||||
|
||||
try {
|
||||
|
||||
|
||||
ItemStackRenderState.LayerRenderState layer = state.newLayer();
|
||||
if(stack.hasFoil())
|
||||
layer.setFoilType(ItemStackRenderState.FoilType.STANDARD);
|
||||
layer.setupBlockModel(model, RenderType.translucent());
|
||||
|
||||
state.render(matrix, buffer, light, OverlayTexture.NO_OVERLAY);
|
||||
|
||||
|
||||
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
||||
renderer.renderStatic(stack, ItemDisplayContext.NONE, light, OverlayTexture.NO_OVERLAY, matrix, buffer, null, model, 0);
|
||||
renderer.render(stack, ItemDisplayContext.NONE, false, matrix, buffer, light, OverlayTexture.NO_OVERLAY, model);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static ItemStack getRenderItemStack(Player player)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
BlockState state = carry.getBlock().getBlock().defaultBlockState();
|
||||
if(carry.getActiveScript().isPresent())
|
||||
{
|
||||
ScriptRender render = carry.getActiveScript().get().scriptRender();
|
||||
if(render.renderNameBlock().isPresent())
|
||||
{
|
||||
state = BuiltInRegistries.BLOCK.get(render.renderNameBlock().get()).get().value().defaultBlockState();
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack renderStack = ItemStack.EMPTY;
|
||||
|
||||
Optional<ModelOverride> ov = ModelOverrideHandler.getModelOverride(state, carry.getContentNbt());
|
||||
if(ov.isPresent())
|
||||
{
|
||||
var renderObj = ov.get().getRenderObject();
|
||||
if(renderObj.right().isPresent())
|
||||
state = renderObj.right().get();
|
||||
else if (renderObj.left().isPresent())
|
||||
renderStack = renderObj.left().get();
|
||||
}
|
||||
|
||||
if(renderStack.isEmpty())
|
||||
renderStack = new ItemStack(state.getBlock());
|
||||
|
||||
return renderStack;
|
||||
}
|
||||
|
||||
public static BlockState getRenderState(Player player)
|
||||
{
|
||||
|
|
@ -293,7 +270,7 @@ public class CarryRenderHelper
|
|||
ScriptRender render = carry.getActiveScript().get().scriptRender();
|
||||
if(render.renderNameBlock().isPresent())
|
||||
{
|
||||
state = BuiltInRegistries.BLOCK.get(render.renderNameBlock().get()).get().value().defaultBlockState();
|
||||
state = BuiltInRegistries.BLOCK.get(render.renderNameBlock().get()).defaultBlockState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -308,14 +285,10 @@ public class CarryRenderHelper
|
|||
return state;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Deprecated
|
||||
public static BakedModel getRenderBlock(Player player)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
||||
Minecraft.getInstance().getModelManager().specialBlockModelRenderer().get().
|
||||
BlockState state = getRenderState(player);
|
||||
BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
|
||||
|
||||
|
|
@ -334,7 +307,6 @@ public class CarryRenderHelper
|
|||
|
||||
return model;
|
||||
}
|
||||
*/
|
||||
|
||||
public static Entity getRenderEntity(Player player)
|
||||
{
|
||||
|
|
@ -346,12 +318,10 @@ public class CarryRenderHelper
|
|||
CarryOnScript script = carry.getActiveScript().get();
|
||||
ScriptRender render = script.scriptRender();
|
||||
if(render.renderNameEntity().isPresent())
|
||||
entity = BuiltInRegistries.ENTITY_TYPE.get(render.renderNameEntity().get()).get().value().create(player.level(), EntitySpawnReason.EVENT);
|
||||
entity = BuiltInRegistries.ENTITY_TYPE.get(render.renderNameEntity().get()).create(player.level());
|
||||
|
||||
if(render.renderNBT().isPresent()) {
|
||||
ValueInput input = TagValueInput.create(new ProblemReporter.ScopedCollector(Constants.LOG), player.registryAccess(), render.renderNBT().get());
|
||||
entity.load(input);
|
||||
}
|
||||
if(render.renderNBT().isPresent())
|
||||
entity.load(render.renderNBT().get());
|
||||
}
|
||||
|
||||
return entity;
|
||||
|
|
@ -379,10 +349,7 @@ public class CarryRenderHelper
|
|||
else if(carry.isCarrying(CarryType.ENTITY))
|
||||
{
|
||||
Entity entity = getRenderEntity(player);
|
||||
float w = entity.getBbWidth();
|
||||
if (Constants.CLIENT_CONFIG.rotateEntitiesSideways)
|
||||
return w - (w*w) * 0.35f;
|
||||
return w * 0.9f;
|
||||
return entity.getBbWidth();
|
||||
}
|
||||
else
|
||||
return 1f;
|
||||
|
|
@ -440,7 +407,7 @@ public class CarryRenderHelper
|
|||
|
||||
public static boolean isChest(Block block)
|
||||
{
|
||||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST || block instanceof ChestBlock;
|
||||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
package tschipp.carryon.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.player.PlayerModel;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.entity.RenderLayerParent;
|
||||
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
||||
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
||||
|
||||
public class CarryingItemRenderLayer<M extends PlayerModel> extends RenderLayer<AvatarRenderState, M> {
|
||||
public CarryingItemRenderLayer(RenderLayerParent<AvatarRenderState, M> renderer) {
|
||||
super(renderer);
|
||||
}
|
||||
@Override
|
||||
public void submit(PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight,
|
||||
AvatarRenderState renderState, float yRot, float xRot) {
|
||||
if (renderState instanceof ICarryOnRenderState carryOnRenderState){
|
||||
CarriedObjectRender.draw(carryOnRenderState.getPlayer(), poseStack, packedLight, Minecraft.getInstance().getDeltaTracker().getGameTimeDeltaPartialTick(true), nodeCollector,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package tschipp.carryon.client.render;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
public interface ICarryOnRenderState {
|
||||
|
||||
CarryOnData getCarryOnData();
|
||||
|
||||
void setCarryOnData(CarryOnData data);
|
||||
|
||||
float getRenderWidth();
|
||||
|
||||
void setRenderWidth(float val);
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
void setPlayer(Player player);
|
||||
|
||||
}
|
||||
|
|
@ -32,26 +32,18 @@ import net.minecraft.nbt.Tag;
|
|||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.AreaEffectCloud;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import net.minecraft.world.level.storage.TagValueOutput;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CarryOnData {
|
||||
|
||||
|
|
@ -60,7 +52,6 @@ public class CarryOnData {
|
|||
private boolean keyPressed = false;
|
||||
private CarryOnScript activeScript;
|
||||
private int selectedSlot = 0;
|
||||
private static final ProblemReporter problemReporter = new ProblemReporter.ScopedCollector(Constants.LOG);
|
||||
|
||||
|
||||
public static final Codec<CarryOnData> CODEC = CompoundTag.CODEC.flatXmap(
|
||||
|
|
@ -87,13 +78,14 @@ public class CarryOnData {
|
|||
public CarryOnData(CompoundTag data)
|
||||
{
|
||||
if(data.contains("type"))
|
||||
this.type = CarryType.valueOf(data.getStringOr("type", "INVALID"));
|
||||
this.type = CarryType.valueOf(data.getString("type"));
|
||||
else
|
||||
this.type = CarryType.INVALID;
|
||||
|
||||
this.nbt = data;
|
||||
|
||||
this.keyPressed = data.getBooleanOr("keyPressed", false);
|
||||
if(data.contains("keyPressed"))
|
||||
this.keyPressed = data.getBoolean("keyPressed");
|
||||
|
||||
if(data.contains("activeScript"))
|
||||
{
|
||||
|
|
@ -101,15 +93,11 @@ public class CarryOnData {
|
|||
this.activeScript = res.getOrThrow((s) -> {throw new RuntimeException("Failed to decode activeScript during CarryOnData serialization: " + s);});
|
||||
}
|
||||
|
||||
this.selectedSlot = data.getIntOr("selected", 0);
|
||||
if(data.contains("selected"))
|
||||
this.selectedSlot = data.getInt("selected");
|
||||
|
||||
}
|
||||
|
||||
public CarryType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public CompoundTag getNbt()
|
||||
{
|
||||
nbt.putString("type", type.toString());
|
||||
|
|
@ -127,13 +115,13 @@ public class CarryOnData {
|
|||
public CompoundTag getContentNbt()
|
||||
{
|
||||
if(type == CarryType.BLOCK && nbt.contains("block"))
|
||||
return nbt.getCompoundOrEmpty("block");
|
||||
return nbt.getCompound("block");
|
||||
else if(type == CarryType.ENTITY && nbt.contains("entity"))
|
||||
return nbt.getCompoundOrEmpty("entity");
|
||||
return nbt.getCompound("entity");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBlock(BlockState state, @Nullable BlockEntity tile, ServerPlayer player, BlockPos pos)
|
||||
public void setBlock(BlockState state, @Nullable BlockEntity tile)
|
||||
{
|
||||
this.type = CarryType.BLOCK;
|
||||
|
||||
|
|
@ -145,9 +133,7 @@ public class CarryOnData {
|
|||
|
||||
if(tile != null)
|
||||
{
|
||||
TagValueOutput output = TagValueOutput.createWithContext(problemReporter, player.registryAccess());
|
||||
tile.saveWithId(output);
|
||||
Tag tileData = output.buildResult();
|
||||
CompoundTag tileData = tile.saveWithId(tile.getLevel().registryAccess());
|
||||
nbt.put("tile", tileData);
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +143,7 @@ public class CarryOnData {
|
|||
if(this.type != CarryType.BLOCK)
|
||||
throw new IllegalStateException("Called getBlock on data that contained " + this.type);
|
||||
|
||||
return NbtUtils.readBlockState(BuiltInRegistries.BLOCK, nbt.getCompoundOrEmpty("block"));
|
||||
return NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), nbt.getCompound("block"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
@ -169,15 +155,14 @@ public class CarryOnData {
|
|||
if(!nbt.contains("tile"))
|
||||
return null;
|
||||
|
||||
return BlockEntity.loadStatic(pos, this.getBlock(), nbt.getCompoundOrEmpty("tile"), lookup);
|
||||
return BlockEntity.loadStatic(pos, this.getBlock(), nbt.getCompound("tile"), lookup);
|
||||
}
|
||||
|
||||
public void setEntity(Entity entity)
|
||||
{
|
||||
this.type = CarryType.ENTITY;
|
||||
TagValueOutput output = TagValueOutput.createWithContext(new ProblemReporter.ScopedCollector(Constants.LOG), entity.registryAccess());
|
||||
entity.save(output);
|
||||
Tag entityData = output.buildResult();
|
||||
CompoundTag entityData = new CompoundTag();
|
||||
entity.save(entityData);
|
||||
nbt.put("entity", entityData);
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +171,7 @@ public class CarryOnData {
|
|||
if(this.type != CarryType.ENTITY)
|
||||
throw new IllegalStateException("Called getEntity on data that contained " + this.type);
|
||||
|
||||
ValueInput in = TagValueInput.create(problemReporter, level.registryAccess(), nbt.getCompoundOrEmpty("entity"));
|
||||
var optionalEntity = EntityType.create(in, level, EntitySpawnReason.BUCKET);
|
||||
var optionalEntity = EntityType.create(nbt.getCompound("entity"), level);
|
||||
if(optionalEntity.isPresent())
|
||||
return optionalEntity.get();
|
||||
|
||||
|
|
@ -208,20 +192,8 @@ public class CarryOnData {
|
|||
this.activeScript = script;
|
||||
}
|
||||
|
||||
public void setCarryingPlayer(Player player)
|
||||
{
|
||||
public void setCarryingPlayer() {
|
||||
this.type = CarryType.PLAYER;
|
||||
nbt.putString("player", player.getStringUUID().toString());
|
||||
}
|
||||
|
||||
public Player getCarryingPlayer(Level level)
|
||||
{
|
||||
if(this.type != CarryType.PLAYER)
|
||||
throw new IllegalStateException("Called getCarryingPlayer on data that contained " + this.type);
|
||||
if(!nbt.contains("player"))
|
||||
return null;
|
||||
UUID uuid = UUID.fromString(nbt.getString("player").get());
|
||||
return level.getServer().getPlayerList().getPlayer(uuid);
|
||||
}
|
||||
|
||||
public boolean isCarrying()
|
||||
|
|
@ -262,7 +234,9 @@ public class CarryOnData {
|
|||
|
||||
public int getTick()
|
||||
{
|
||||
return this.nbt.getIntOr("tick", -1);
|
||||
if(!this.nbt.contains("tick"))
|
||||
return -1;
|
||||
return this.nbt.getInt("tick");
|
||||
}
|
||||
|
||||
public void setTick(int tick) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class CarryOnDataManager {
|
|||
|
||||
public static void setCarryData(Player player, CarryOnData data)
|
||||
{
|
||||
data.setSelected(player.getInventory().getSelectedSlot());
|
||||
data.setSelected(player.getInventory().selected);
|
||||
data.setTick(player.tickCount);
|
||||
Services.PLATFORM.setCarryData(player, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,24 +22,24 @@ package tschipp.carryon.common.carry;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Entity.RemovalReason;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.TamableAnimal;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.storage.TagValueOutput;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -89,18 +89,15 @@ public class PickupHandler {
|
|||
|
||||
public static boolean tryPickUpBlock(ServerPlayer player, BlockPos pos, Level level, @Nullable BiFunction<BlockState, BlockPos, Boolean> pickupCallback)
|
||||
{
|
||||
if(!canCarryGeneral(player, Vec3.atCenterOf(pos)))
|
||||
if(!canCarryGeneral(player, Vec3.atCenterOf(pos))) //Necessary
|
||||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
CompoundTag nbt = null;
|
||||
if(blockEntity != null) {
|
||||
TagValueOutput output = TagValueOutput.createWithContext(new ProblemReporter.ScopedCollector(Constants.LOG), level.registryAccess());
|
||||
blockEntity.saveWithId(output);
|
||||
nbt = output.buildResult();
|
||||
}
|
||||
if(blockEntity != null)
|
||||
nbt = blockEntity.saveWithId(level.registryAccess());
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectBlock(state, level, pos, nbt);
|
||||
boolean overrideChecks = result.map(CarryOnScript::overrideChecks).orElse(false);
|
||||
|
|
@ -108,10 +105,6 @@ public class PickupHandler {
|
|||
if(!ListHandler.isPermitted(state.getBlock()))
|
||||
return false;
|
||||
|
||||
// Reject pickup of Double blocks, if they use the vanilla property
|
||||
if(hasPropertyType(state, DoorBlock.HALF))
|
||||
return false;
|
||||
|
||||
if(!overrideChecks && (state.getDestroySpeed(level, pos) == -1 && !player.isCreative() && !Constants.COMMON_CONFIG.settings.pickupUnbreakableBlocks))
|
||||
return false;
|
||||
|
||||
|
|
@ -146,10 +139,10 @@ public class PickupHandler {
|
|||
|
||||
String cmd = script.scriptEffects().commandInit();
|
||||
if(!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
carry.setBlock(state, blockEntity, player, pos);
|
||||
carry.setBlock(state, blockEntity);
|
||||
|
||||
level.removeBlockEntity(pos);
|
||||
level.removeBlock(pos, false);
|
||||
|
|
@ -158,7 +151,7 @@ public class PickupHandler {
|
|||
level.playSound(null, pos, state.getSoundType().getHitSound(), SoundSource.BLOCKS, 1.0f, 0.5f);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -177,13 +170,10 @@ public class PickupHandler {
|
|||
|
||||
if (entity instanceof TamableAnimal tame)
|
||||
{
|
||||
EntityReference<LivingEntity> ref = tame.getOwnerReference();
|
||||
if (ref != null) {
|
||||
UUID owner = ref.getUUID();
|
||||
UUID playerID = player.getGameProfile().id();
|
||||
if (!owner.equals(playerID))
|
||||
return false;
|
||||
}
|
||||
UUID owner = tame.getOwnerUUID();
|
||||
UUID playerID = player.getGameProfile().getId();
|
||||
if (owner != null && !owner.equals(playerID))
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<CarryOnScript> result = ScriptManager.inspectEntity(entity);
|
||||
|
|
@ -213,7 +203,7 @@ public class PickupHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean doPickup = pickupCallback == null || pickupCallback.apply(entity);
|
||||
boolean doPickup = pickupCallback == null ? true : pickupCallback.apply(entity);
|
||||
if(!doPickup)
|
||||
return false;
|
||||
|
||||
|
|
@ -241,17 +231,17 @@ public class PickupHandler {
|
|||
if (result.isPresent()) {
|
||||
String cmd = result.get().scriptEffects().commandInit();
|
||||
if (!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
otherPlayer.startRiding(player, true, false);
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), true), player.level());
|
||||
carry.setCarryingPlayer(otherPlayer);
|
||||
otherPlayer.startRiding(player, true);
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), true), (ServerLevel) player.level());
|
||||
carry.setCarryingPlayer();
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
@ -259,14 +249,14 @@ public class PickupHandler {
|
|||
entity.ejectPassengers();
|
||||
entity.stopRiding();
|
||||
if (entity instanceof Animal animal) {
|
||||
animal.dropLeash();
|
||||
animal.dropLeash(true, true);
|
||||
}
|
||||
|
||||
if(result.isPresent())
|
||||
{
|
||||
String cmd = result.get().scriptEffects().commandInit();
|
||||
if(!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
carry.setEntity(entity);
|
||||
|
|
@ -276,16 +266,8 @@ public class PickupHandler {
|
|||
CarryOnDataManager.setCarryData(player, carry);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 100000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> boolean hasPropertyType(BlockState state, Property<T> prop) {
|
||||
for (var p : state.getProperties()) {
|
||||
if(p.getValueClass().equals(prop.getValueClass()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,16 +29,17 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.animal.equine.Horse;
|
||||
import net.minecraft.world.entity.animal.horse.Horse;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.gamerules.GameRules;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
|
@ -92,14 +93,11 @@ public class PlacementHandler
|
|||
if (!doPlace)
|
||||
return false;
|
||||
|
||||
if(level.isOutsideBuildHeight(pos))
|
||||
return false;
|
||||
|
||||
if (carry.getActiveScript().isPresent()) {
|
||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||
String cmd = effects.commandPlace();
|
||||
if (!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
level.setBlockAndUpdate(pos, state);
|
||||
|
|
@ -114,7 +112,8 @@ public class PlacementHandler
|
|||
player.playSound(state.getSoundType().getPlaceSound(), 1.0f, 0.5f);
|
||||
level.playSound(null, pos, state.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0f, 0.5f);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
player.removeEffect(MobEffects.SLOWNESS);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.removeEffect(MobEffects.MOVEMENT_SLOWDOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +124,7 @@ public class PlacementHandler
|
|||
placementState = state;
|
||||
|
||||
for (var prop : placementState.getProperties()) {
|
||||
if (prop.getValueClass() == Direction.class)
|
||||
if (prop instanceof DirectionProperty)
|
||||
state = updateProperty(state, placementState, prop);
|
||||
if (prop.getValueClass() == Direction.Axis.class)
|
||||
state = updateProperty(state, placementState, prop);
|
||||
|
|
@ -177,14 +176,15 @@ public class PlacementHandler
|
|||
Vec3 placementPos = Vec3.atBottomCenterOf(pos);
|
||||
|
||||
if (carry.isCarrying(CarryType.PLAYER)) {
|
||||
Entity otherPlayer = carry.getCarryingPlayer(level);
|
||||
Entity otherPlayer = player.getFirstPassenger();
|
||||
player.ejectPassengers();
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), false), player.level());
|
||||
Services.PLATFORM.sendPacketToAllPlayers(Constants.PACKET_ID_START_RIDING_OTHER, new ClientboundStartRidingOtherPlayerPacket(player.getId(), otherPlayer.getId(), false), player.serverLevel());
|
||||
carry.clear();
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
otherPlayer.teleportTo(placementPos.x, placementPos.y, placementPos.z);
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
player.removeEffect(MobEffects.SLOWNESS);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.removeEffect(MobEffects.MOVEMENT_SLOWDOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ public class PlacementHandler
|
|||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||
String cmd = effects.commandPlace();
|
||||
if (!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
level.addFreshEntity(entity);
|
||||
|
|
@ -209,7 +209,8 @@ public class PlacementHandler
|
|||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
carry.clear();
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
player.removeEffect(MobEffects.SLOWNESS);
|
||||
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
|
||||
player.removeEffect(MobEffects.MOVEMENT_SLOWDOWN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -257,27 +258,26 @@ public class PlacementHandler
|
|||
level.addFreshEntity(entityHeld);
|
||||
entityHeld.teleportTo(tempX, tempY, tempZ);
|
||||
}
|
||||
entityHeld.startRiding(topEntity, false,false);
|
||||
entityHeld.startRiding(topEntity, false);
|
||||
} else {
|
||||
if (carry.isCarrying(CarryType.ENTITY)) {
|
||||
entityHeld.setPos(entityClicked.getX(), entityClicked.getY(), entityClicked.getZ());
|
||||
level.addFreshEntity(entityHeld);
|
||||
}
|
||||
entityHeld.startRiding(topEntity, false,false);
|
||||
entityHeld.startRiding(topEntity, false);
|
||||
}
|
||||
|
||||
if (carry.getActiveScript().isPresent()) {
|
||||
ScriptEffects effects = carry.getActiveScript().get().scriptEffects();
|
||||
String cmd = effects.commandPlace();
|
||||
if (!cmd.isEmpty())
|
||||
player.level().getServer().getCommands().performPrefixedCommand(player.level().getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().name() + " run " + cmd);
|
||||
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
|
||||
}
|
||||
|
||||
player.swing(InteractionHand.MAIN_HAND, true);
|
||||
carry.clear();
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||
player.removeEffect(MobEffects.SLOWNESS);
|
||||
} else {
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.LAVA_POP, SoundSource.PLAYERS, 0.5F, 0.5F);
|
||||
}
|
||||
|
|
@ -290,10 +290,10 @@ public class PlacementHandler
|
|||
public static void placeCarriedOnDeath(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolean died)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(oldPlayer);
|
||||
if (oldPlayer.level().getGameRules().get(GameRules.KEEP_INVENTORY) || !died) {
|
||||
if (oldPlayer.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || !died) {
|
||||
if (!carry.isCarrying(CarryType.PLAYER)) {
|
||||
CarryOnDataManager.setCarryData(newPlayer, carry);
|
||||
newPlayer.getInventory().setSelectedSlot(oldPlayer.getInventory().getSelectedSlot());
|
||||
newPlayer.getInventory().selected = oldPlayer.getInventory().selected;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -321,7 +321,6 @@ public class PlacementHandler
|
|||
}
|
||||
carry.clear();
|
||||
CarryOnDataManager.setCarryData(player, carry);
|
||||
player.removeEffect(MobEffects.SLOWNESS);
|
||||
}
|
||||
|
||||
private static BlockPos getDeathPlacementPos(BlockState state, ServerPlayer player)
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
package tschipp.carryon.common.carry.compat;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CarryOnModHooks {
|
||||
|
||||
public record CanPickupBlockHook(ServerPlayer player, BlockPos pos, BlockState state) {
|
||||
|
||||
}
|
||||
|
||||
public record CanPickupEntityHook(ServerPlayer player, Entity entity) {
|
||||
|
||||
}
|
||||
|
||||
public record SaveBlockHook(ServerPlayer player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,8 +28,6 @@ import net.minecraft.commands.Commands;
|
|||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.permissions.Permission;
|
||||
import net.minecraft.server.permissions.PermissionLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -56,11 +54,11 @@ public class CommandCarryOn
|
|||
|
||||
.then(Commands.literal("clear").executes(cmd -> handleClear(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||
|
||||
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))).executes(cmd -> handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
|
||||
.then(Commands.literal("place").requires(src -> src.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))).executes(cmd -> handlePlace(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||
.then(Commands.literal("place").requires(src -> src.hasPermission(2)).executes(cmd -> handlePlace(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||
|
||||
.then(Commands.literal("place").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))).executes(cmd -> handlePlace(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
.then(Commands.literal("place").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handlePlace(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class CarryConfig
|
|||
)
|
||||
public Settings settings = new Settings();
|
||||
|
||||
@Category(value="settings", translation = "carryon.category.settings")
|
||||
@Category("settings")
|
||||
public static class Settings
|
||||
{
|
||||
@Property(
|
||||
|
|
@ -171,8 +171,7 @@ public class CarryConfig
|
|||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Usually all the block state information is retained when placing a block that was picked up. But some information is changed to a modified property, like rotation or orientation. In this list, add additional properties that should NOT be saved and instead be updated when placed. Format: modid:block[propertyname]. Note: You don't need to add an entry for every subtype of a same block. For example, we only add an entry for one type of slab, but the change is applied to all slabs.",
|
||||
validationRegex = "([a-zA-Z0-9_]+:[a-zA-Z0-9_]+)\\[([a-zA-Z0-9_,]+)\\]"
|
||||
description = "Usually all the block state information is retained when placing a block that was picked up. But some information is changed to a modified property, like rotation or orientation. In this list, add additional properties that should NOT be saved and instead be updated when placed. Format: modid:block[propertyname]. Note: You don't need to add an entry for every subtype of a same block. For example, we only add an entry for one type of slab, but the change is applied to all slabs."
|
||||
)
|
||||
public String[] placementStateExceptions = {
|
||||
"minecraft:chest[type]",
|
||||
|
|
@ -205,27 +204,24 @@ public class CarryConfig
|
|||
//Whitelist
|
||||
public Whitelist whitelist = new Whitelist();
|
||||
|
||||
@Category(value="whitelist", translation = "carryon.category.whitelist")
|
||||
@Category("whitelist")
|
||||
public static class Whitelist
|
||||
{
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Entities that CAN be picked up (useWhitelistEntities must be true)",
|
||||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
description = "Entities that CAN be picked up (useWhitelistEntities must be true)"
|
||||
)
|
||||
public String[] allowedEntities = {};
|
||||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Blocks that CAN be picked up (useWhitelistBlocks must be true)",
|
||||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
description = "Blocks that CAN be picked up (useWhitelistBlocks must be true)"
|
||||
)
|
||||
public String[] allowedBlocks = {};
|
||||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)",
|
||||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
description = "Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)"
|
||||
)
|
||||
public String[] allowedStacking = {};
|
||||
}
|
||||
|
|
@ -237,13 +233,12 @@ public class CarryConfig
|
|||
)
|
||||
public Blacklist blacklist = new Blacklist();
|
||||
|
||||
@Category(value="blacklist", translation = "carryon.category.blacklist")
|
||||
@Category("blacklist")
|
||||
public static class Blacklist
|
||||
{
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Blocks that cannot be picked up",
|
||||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
description = "Blocks that cannot be picked up"
|
||||
)
|
||||
public String[] forbiddenTiles = {
|
||||
"#forge:immovable", "#forge:relocation_not_supported", "#neoforge:immovable", "#neoforge:relocation_not_supported", "minecraft:end_portal", "minecraft:piston_head",
|
||||
|
|
@ -284,14 +279,12 @@ public class CarryConfig
|
|||
"modern_industrialization:*_item_pipe",
|
||||
"modern_industrialization:fluid_pipe",
|
||||
"modern_industrialization:*_fluid_pipe",
|
||||
"yigd:*", "domum_ornamentum:*", "connectiblechains:*",
|
||||
"cobblemon:*", "snowrealmagic:*", "forbidden_arcanus:black_hole", "domum_ornamentum:*", "sgjourney:*", "copycats:*", "expandedstorage:*", "replication:*"
|
||||
"snowrealmagic:*"
|
||||
};
|
||||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Entities that cannot be picked up",
|
||||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
description = "Entities that cannot be picked up"
|
||||
)
|
||||
public String[] forbiddenEntities = {
|
||||
"#c:capturing_not_supported", "#c:teleporting_not_supported",
|
||||
|
|
@ -301,18 +294,15 @@ public class CarryConfig
|
|||
"minecraft:interaction", "minecraft:marker", "minecraft:block_display", "minecraft:item_display", "minecraft:text_display",
|
||||
"animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart",
|
||||
"animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*",
|
||||
"securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body", "littletiles:*",
|
||||
"connectiblechains:*", "cobblemon:*", "create:*", "swem:*", "toms_mobs:*"
|
||||
"securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body", "littletiles:*"
|
||||
};
|
||||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Entities that cannot have other entities stacked on top of them",
|
||||
validationRegex = "(#?[a-zA-Z0-9_*]+:[a-zA-Z0-9_*]*(?:\\*|[a-zA-Z0-9_]*)(?:\\*|[a-zA-Z0-9_]*)?)"
|
||||
description = "Entities that cannot have other entities stacked on top of them"
|
||||
)
|
||||
public String[] forbiddenStacking = {
|
||||
"minecraft:horse",
|
||||
"minecraft:ender_dragon"
|
||||
"minecraft:horse"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -323,20 +313,18 @@ public class CarryConfig
|
|||
)
|
||||
public CustomPickupConditions customPickupConditions = new CustomPickupConditions();
|
||||
|
||||
@Category(value="customPickupConditions", translation = "carryon.category.custompickupconditions")
|
||||
@Category("customPickupConditions")
|
||||
public static class CustomPickupConditions
|
||||
{
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Custom Pickup Conditions for Blocks",
|
||||
validationRegex = "([a-zA-Z0-9_*\\-:]+(?:\\[[^\\]]*\\])?)\\(([\\w_]+)\\)"
|
||||
description = "Custom Pickup Conditions for Blocks"
|
||||
)
|
||||
public String[] customPickupConditionsBlocks = {};
|
||||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Custom Pickup Conditions for Entities",
|
||||
validationRegex = "([a-zA-Z0-9_*\\-:]+(?:\\[[^\\]]*\\])?)\\(([\\w_]+)\\)"
|
||||
description = "Custom Pickup Conditions for Entities"
|
||||
)
|
||||
public String[] customPickupConditionsEntities = {};
|
||||
}
|
||||
|
|
@ -352,12 +340,6 @@ public class CarryConfig
|
|||
)
|
||||
public boolean facePlayer = false;
|
||||
|
||||
@Property(
|
||||
type = PropertyType.BOOLEAN,
|
||||
description = "If Entities should be rotated sideways when carried"
|
||||
)
|
||||
public boolean rotateEntitiesSideways = false;
|
||||
|
||||
@Property(
|
||||
type = PropertyType.BOOLEAN,
|
||||
description = "Arms should render on sides when carrying. Set to false if you experience issues with mods that replace the player model (like MoBends, etc)"
|
||||
|
|
@ -366,8 +348,7 @@ public class CarryConfig
|
|||
|
||||
@Property(
|
||||
type = PropertyType.STRING_ARRAY,
|
||||
description = "Model Overrides based on NBT or Meta. Advanced users only! Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config",
|
||||
validationRegex = "([a-zA-Z0-9_]+:[a-zA-Z0-9_]+(?:\\[[^\\]]*\\])?(?:\\{[^}]*\\})?)(?:;(\\d+))?->(?:\\((item|block)\\))?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+(?:\\[[^\\]]*\\])?(?:\\{[^}]*\\})?)(?:;(\\d+))?"
|
||||
description = "Model Overrides based on NBT or Meta. Advanced users only! Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config"
|
||||
)
|
||||
public String[] modelOverrides = {
|
||||
"minecraft:redstone_wire->(item)minecraft:redstone",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ package tschipp.carryon.common.config;
|
|||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
|
@ -119,8 +119,8 @@ public class ListHandler {
|
|||
ALLOWED_TILES_TAGS.clear();
|
||||
PROPERTY_EXCEPTION_CLASSES.clear();
|
||||
|
||||
Map<Identifier, TagKey<Block>> blocktags = BuiltInRegistries.BLOCK.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<Identifier, TagKey<EntityType<?>>> entitytags = BuiltInRegistries.ENTITY_TYPE.listTagIds().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<ResourceLocation, TagKey<Block>> blocktags = BuiltInRegistries.BLOCK.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
Map<ResourceLocation, TagKey<EntityType<?>>> entitytags = BuiltInRegistries.ENTITY_TYPE.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
|
||||
List<String> forbidden = new ArrayList<>(List.of(Constants.COMMON_CONFIG.blacklist.forbiddenTiles));
|
||||
forbidden.add("#carryon:block_blacklist");
|
||||
|
|
@ -152,7 +152,7 @@ public class ListHandler {
|
|||
continue;
|
||||
String name = propString.substring(0, propString.indexOf("["));
|
||||
String props = propString.substring(propString.indexOf("[") + 1, propString.indexOf("]"));
|
||||
Block blk = BuiltInRegistries.BLOCK.get(Identifier.parse(name)).get().value();
|
||||
Block blk = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(name));
|
||||
for(String propName : props.split(",")) {
|
||||
for (Property<?> prop : blk.defaultBlockState().getProperties()) {
|
||||
if (prop.getName().equals(propName))
|
||||
|
|
@ -162,16 +162,16 @@ public class ListHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static <T> void addTag(String tag, Map<Identifier, TagKey<T>> tagMap, List<TagKey<T>> tags) {
|
||||
private static <T> void addTag(String tag, Map<ResourceLocation, TagKey<T>> tagMap, List<TagKey<T>> tags) {
|
||||
String sub = tag.substring(1);
|
||||
TagKey<T> t = tagMap.get(Identifier.parse(sub));
|
||||
TagKey<T> t = tagMap.get(ResourceLocation.parse(sub));
|
||||
if (t != null)
|
||||
tags.add(t);
|
||||
}
|
||||
|
||||
private static <T> void addWithWildcards(List<String> entries, Set<String> toAddTo, Registry<T> registry, Map<Identifier, TagKey<T>> tags, List<TagKey<T>> toAddTags) {
|
||||
private static <T> void addWithWildcards(List<String> entries, Set<String> toAddTo, Registry<T> registry, Map<ResourceLocation, TagKey<T>> tags, List<TagKey<T>> toAddTags) {
|
||||
|
||||
Identifier[] keys = registry.keySet().toArray(new Identifier[0]);
|
||||
ResourceLocation[] keys = registry.keySet().toArray(new ResourceLocation[0]);
|
||||
for (int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
String curr = entries.get(i);
|
||||
|
|
@ -181,7 +181,7 @@ public class ListHandler {
|
|||
{
|
||||
String[] filter = curr.replace("*", ",").split(",");
|
||||
|
||||
for (Identifier key : keys)
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
|
||||
if (containsAll(key.toString(), filter))
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public class PickupCondition
|
|||
private BlockResult parseState(String state)
|
||||
{
|
||||
try {
|
||||
BlockResult result = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK, state, false);
|
||||
BlockResult result = BlockStateParser.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), state, false);
|
||||
return result;
|
||||
} catch (CommandSyntaxException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import net.minecraft.advancements.AdvancementHolder;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
|
@ -127,8 +127,8 @@ public final class Matchables
|
|||
@Override
|
||||
public boolean matches(ServerPlayer player)
|
||||
{
|
||||
ServerAdvancementManager manager = player.level().getServer().getAdvancements();
|
||||
AdvancementHolder adv = manager.get(Identifier.parse(advancement.isEmpty() ? "" : advancement));
|
||||
ServerAdvancementManager manager = player.server.getAdvancements();
|
||||
AdvancementHolder adv = manager.get(ResourceLocation.parse(advancement.isEmpty() ? "" : advancement));
|
||||
|
||||
boolean achievement = adv == null ? true : player.getAdvancements().getOrStartProgress(adv).isDone();
|
||||
return achievement;
|
||||
|
|
@ -167,7 +167,7 @@ public final class Matchables
|
|||
if (cond == null || cond.isEmpty())
|
||||
return true;
|
||||
|
||||
Scoreboard score = player.level().getScoreboard();
|
||||
Scoreboard score = player.getScoreboard();
|
||||
String numb;
|
||||
String scorename;
|
||||
int iE = cond.indexOf("=");
|
||||
|
|
|
|||
|
|
@ -23,13 +23,11 @@ package tschipp.carryon.common.scripting;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.TagValueOutput;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptObject.ScriptObjectBlock;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptObject.ScriptObjectEntity;
|
||||
|
|
@ -69,9 +67,8 @@ public class ScriptManager
|
|||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
||||
TagValueOutput output = TagValueOutput.createWithContext(new ProblemReporter.ScopedCollector(Constants.LOG), entity.registryAccess());
|
||||
entity.save(output);
|
||||
CompoundTag tag = output.buildResult();
|
||||
CompoundTag tag = new CompoundTag();
|
||||
entity.save(tag);
|
||||
|
||||
for (CarryOnScript script : SCRIPTS)
|
||||
{
|
||||
|
|
@ -103,7 +100,7 @@ public class ScriptManager
|
|||
|
||||
boolean matchblock = true;
|
||||
if(scBlock.typeNameBlock().isPresent())
|
||||
matchblock = block == BuiltInRegistries.BLOCK.get(scBlock.typeNameBlock().get()).get().value();
|
||||
matchblock = block == BuiltInRegistries.BLOCK.get(scBlock.typeNameBlock().get());
|
||||
boolean matchnbt = scBlock.typeBlockTag().matches(nbt);
|
||||
boolean matchhardness = scBlock.typeHardness().matches(hardness);
|
||||
boolean matchresistance = scBlock.typeResistance().matches(resistance);
|
||||
|
|
|
|||
|
|
@ -20,44 +20,61 @@
|
|||
|
||||
package tschipp.carryon.common.scripting;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.FileToIdConverter;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener<CarryOnScript>
|
||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
||||
{
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
public ScriptReloadListener()
|
||||
{
|
||||
super(CarryOnScript.CODEC, FileToIdConverter.json("carryon/scripts"));
|
||||
super(GSON, "carryon/scripts");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(Map<Identifier, CarryOnScript> scripts, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller profilerFiller)
|
||||
protected void apply(Map<ResourceLocation, JsonElement> objects, ResourceManager manager, ProfilerFiller profiler)
|
||||
{
|
||||
ScriptManager.SCRIPTS.clear();
|
||||
|
||||
scripts.forEach((path, script) -> {
|
||||
if (script.isValid())
|
||||
ScriptManager.SCRIPTS.add(script);
|
||||
});
|
||||
try {
|
||||
objects.forEach((path, jsonElem) -> {
|
||||
DataResult<CarryOnScript> res = CarryOnScript.CODEC.parse(JsonOps.INSTANCE, jsonElem);
|
||||
if(res.result().isPresent())
|
||||
{
|
||||
CarryOnScript script = res.result().get();
|
||||
if (script.isValid())
|
||||
ScriptManager.SCRIPTS.add(script);
|
||||
}
|
||||
else
|
||||
Constants.LOG.warn("Error while parsing script: " + res.error().get().message());
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ScriptManager.SCRIPTS.sort((s1, s2) -> Long.compare(s2.priority(), s1.priority()));
|
||||
}
|
||||
|
||||
|
||||
public static void syncScriptsWithClient(ServerPlayer player)
|
||||
{
|
||||
if (player != null)
|
||||
|
|
|
|||
|
|
@ -1,107 +0,0 @@
|
|||
package tschipp.carryon.compat;
|
||||
|
||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import tschipp.carryon.config.AnnotationData;
|
||||
import tschipp.carryon.config.BuiltCategory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public record ClothConfigCompat(BuiltConfig client, BuiltConfig common, Runnable onSave) {
|
||||
|
||||
public static Screen getConfigScreen(BuiltConfig client, BuiltConfig common, Screen parentScreen, Runnable onSave) {
|
||||
ConfigBuilder builder = ConfigBuilder.create()
|
||||
.setParentScreen(parentScreen)
|
||||
.setTitle(Component.translatable("key.category.carryon.key.carry.category"));
|
||||
|
||||
buildConfigType(client, builder, "Client Config");
|
||||
buildConfigType(common, builder, "Common Config");
|
||||
|
||||
builder.setSavingRunnable(onSave);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static void buildConfigType(BuiltConfig cfg, ConfigBuilder builder, String name) {
|
||||
ConfigCategory configCategory = builder.getOrCreateCategory(Component.literal(name));
|
||||
buildProperties(cfg, configCategory, builder, null);
|
||||
}
|
||||
|
||||
|
||||
private static void buildCategory(BuiltCategory category, ConfigCategory categoryBuilder, ConfigBuilder builder) {
|
||||
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
|
||||
SubCategoryBuilder subBuilder = entryBuilder.startSubCategory(Component.translatable(category.translation));
|
||||
|
||||
buildProperties(category, categoryBuilder, builder, subBuilder);
|
||||
}
|
||||
|
||||
private static void buildProperties(BuiltCategory category, ConfigCategory categoryBuilder, ConfigBuilder builder, @Nullable SubCategoryBuilder subBuilder) {
|
||||
category.categories.forEach(cat -> {
|
||||
buildCategory(cat, categoryBuilder, builder);
|
||||
});
|
||||
|
||||
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
|
||||
|
||||
category.properties.forEach(propertyData -> {
|
||||
try {
|
||||
AnnotationData data = propertyData.getData();
|
||||
var entry =
|
||||
switch (data.type()) {
|
||||
case BOOLEAN ->
|
||||
entryBuilder.startBooleanToggle(Component.literal(propertyData.getField().getName()), propertyData.getBoolean())
|
||||
.setTooltip(Component.literal(data.description()))
|
||||
.setDefaultValue(propertyData.getDefaultBoolean())
|
||||
.setSaveConsumer((Consumer<Boolean>) propertyData.getSetter())
|
||||
.build();
|
||||
case INT ->
|
||||
entryBuilder.startIntField(Component.literal(propertyData.getField().getName()), propertyData.getInt())
|
||||
.setTooltip(Component.literal(data.description()))
|
||||
.setDefaultValue(propertyData.getDefaultInt())
|
||||
.setMin(data.min())
|
||||
.setMax(data.max())
|
||||
.setSaveConsumer((Consumer<Integer>) propertyData.getSetter())
|
||||
.build();
|
||||
case DOUBLE ->
|
||||
entryBuilder.startDoubleField(Component.literal(propertyData.getField().getName()), propertyData.getDouble())
|
||||
.setTooltip(Component.literal(data.description()))
|
||||
.setDefaultValue(propertyData.getDefaultDouble())
|
||||
.setMin(data.minD())
|
||||
.setMax(data.maxD())
|
||||
.setSaveConsumer((Consumer<Double>) propertyData.getSetter())
|
||||
.build();
|
||||
case STRING_ARRAY ->
|
||||
entryBuilder.startStrList(Component.literal(propertyData.getField().getName()), List.of(propertyData.getStringArray()))
|
||||
.setTooltip(Component.literal(data.description()))
|
||||
.setInsertInFront(true)
|
||||
.setDefaultValue(List.of(propertyData.getDefaultStringArray()))
|
||||
.setCellErrorSupplier(str -> str.matches(data.validationRegex()) ? Optional.empty() : Optional.of(Component.literal("Invalid Format")))
|
||||
.setSaveConsumer((Consumer<List<String>>) propertyData.getSetter())
|
||||
.build();
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if(subBuilder == null)
|
||||
categoryBuilder.addEntry(entry);
|
||||
else
|
||||
subBuilder.add(entry);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
if(subBuilder != null)
|
||||
categoryBuilder.addEntry(subBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -29,8 +29,7 @@ public record AnnotationData(
|
|||
PropertyType type,
|
||||
String description,
|
||||
int min, int max,
|
||||
double minD, double maxD,
|
||||
String validationRegex
|
||||
double minD, double maxD
|
||||
) {
|
||||
|
||||
public static AnnotationData getData(Field field) {
|
||||
|
|
@ -39,8 +38,7 @@ public record AnnotationData(
|
|||
annotation.type(),
|
||||
annotation.description(),
|
||||
annotation.min(), annotation.max(),
|
||||
annotation.minD(), annotation.maxD(),
|
||||
annotation.validationRegex()
|
||||
annotation.minD(), annotation.maxD()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,9 @@ public class BuiltCategory {
|
|||
public final String categoryDesc;
|
||||
public final String category;
|
||||
|
||||
public final String translation;
|
||||
|
||||
public BuiltCategory(String categoryDesc, String category, String translation) {
|
||||
public BuiltCategory(String categoryDesc, String category) {
|
||||
this.categoryDesc = categoryDesc;
|
||||
this.category = category;
|
||||
this.translation = translation;
|
||||
}
|
||||
|
||||
public Optional<PropertyData> getProperty(String id) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class BuiltConfig extends BuiltCategory {
|
|||
public final String fileName;
|
||||
|
||||
public BuiltConfig(String fileName) {
|
||||
super(null, fileName, "key.carry.category");
|
||||
super(null, fileName);
|
||||
this.fileName = fileName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class ConfigLoader {
|
|||
if (configClass.isAnnotationPresent(Config.class)) {
|
||||
category = new BuiltConfig(configClass.getAnnotation(Config.class).value());
|
||||
} else if (configClass.isAnnotationPresent(Category.class)) {
|
||||
category = new BuiltCategory(categoryDesc, configClass.getAnnotation(Category.class).value(), configClass.getAnnotation(Category.class).translation());
|
||||
category = new BuiltCategory(categoryDesc, configClass.getAnnotation(Category.class).value());
|
||||
} else {
|
||||
throw new IllegalStateException("Config does not contain any @Config annotation or @Category");
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ public class ConfigLoader {
|
|||
if (type.equals(PropertyType.CATEGORY)) {
|
||||
category.categories.add(buildCategory(field.getAnnotation(Property.class).description(), field.get(object)));
|
||||
} else {
|
||||
category.properties.add(new PropertyData(object, field, AnnotationData.getData(field), field.get(object)));
|
||||
category.properties.add(new PropertyData(object, field, AnnotationData.getData(field)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,49 +21,15 @@
|
|||
package tschipp.carryon.config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class PropertyData {
|
||||
|
||||
Object fieldClass;
|
||||
Field field;
|
||||
AnnotationData data;
|
||||
Object defaultValue;
|
||||
Consumer<?> setter;
|
||||
|
||||
public PropertyData(Object fieldClass, Field field, AnnotationData data, Object defaultValue) {
|
||||
this.fieldClass = fieldClass;
|
||||
this.field = field;
|
||||
this.data = data;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public Consumer<?> getSetter() {
|
||||
return setter;
|
||||
}
|
||||
|
||||
public void setSetter(Consumer<?> setter) {
|
||||
this.setter = setter;
|
||||
}
|
||||
|
||||
public AnnotationData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public Object getFieldClass() {
|
||||
return fieldClass;
|
||||
}
|
||||
public record PropertyData(Object fieldClass, Field field, AnnotationData data) {
|
||||
|
||||
public String getId() {
|
||||
return field.getName();
|
||||
return field().getName();
|
||||
}
|
||||
|
||||
public boolean getBoolean() throws IllegalAccessException {
|
||||
return field.getBoolean(fieldClass);
|
||||
return field().getBoolean(fieldClass());
|
||||
}
|
||||
|
||||
public void setBoolean(boolean _boolean) {
|
||||
|
|
@ -74,12 +40,8 @@ public class PropertyData {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean getDefaultBoolean() {
|
||||
return (boolean)defaultValue;
|
||||
}
|
||||
|
||||
public int getInt() throws IllegalAccessException {
|
||||
return field.getInt(fieldClass);
|
||||
return field().getInt(fieldClass());
|
||||
}
|
||||
|
||||
public void setInt(int _int) {
|
||||
|
|
@ -90,12 +52,8 @@ public class PropertyData {
|
|||
}
|
||||
}
|
||||
|
||||
public int getDefaultInt() {
|
||||
return (int)defaultValue;
|
||||
}
|
||||
|
||||
public double getDouble() throws IllegalAccessException {
|
||||
return field.getDouble(fieldClass);
|
||||
return field().getDouble(fieldClass());
|
||||
}
|
||||
|
||||
public void setDouble(double _double) {
|
||||
|
|
@ -106,12 +64,8 @@ public class PropertyData {
|
|||
}
|
||||
}
|
||||
|
||||
public double getDefaultDouble() {
|
||||
return (double)defaultValue;
|
||||
}
|
||||
|
||||
public String[] getStringArray() throws IllegalAccessException {
|
||||
return (String[])field.get(fieldClass);
|
||||
return (String[])field().get(fieldClass());
|
||||
}
|
||||
|
||||
public void setStringArray(String[] arr)
|
||||
|
|
@ -122,8 +76,4 @@ public class PropertyData {
|
|||
//Ignore
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getDefaultStringArray() {
|
||||
return (String[])defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,5 +29,4 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Category {
|
||||
String value();
|
||||
String translation() default "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.lang.annotation.Target;
|
|||
public @interface Property {
|
||||
|
||||
|
||||
|
||||
PropertyType type();
|
||||
String description();
|
||||
|
||||
|
|
@ -40,6 +41,4 @@ public @interface Property {
|
|||
|
||||
double minD() default Double.MIN_VALUE;
|
||||
double maxD() default Double.MAX_VALUE;
|
||||
|
||||
String validationRegex() default ".*";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.client.entity.ClientAvatarEntity;
|
||||
import net.minecraft.client.model.player.PlayerModel;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
||||
import net.minecraft.world.entity.Avatar;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.client.render.CarryingItemRenderLayer;
|
||||
|
||||
@Mixin(AvatarRenderer.class)
|
||||
public abstract class AvatarRendererMixin<AvatarlikeEntity extends Avatar & ClientAvatarEntity> extends LivingEntityRenderer<AvatarlikeEntity, AvatarRenderState, PlayerModel> {
|
||||
|
||||
public AvatarRendererMixin(Context context, PlayerModel model, float shadowRadius) {
|
||||
super(context, model, shadowRadius);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;Z)V", at = @At("RETURN"))
|
||||
public void init(EntityRendererProvider.Context context, boolean slim, CallbackInfo info) {
|
||||
//Player
|
||||
this.addLayer(new CarryingItemRenderLayer<>(this));
|
||||
}
|
||||
}
|
||||
|
|
@ -48,14 +48,14 @@ public abstract class EntityMixin
|
|||
@Shadow
|
||||
public boolean hasPassenger(Entity pEntity) {throw new IllegalStateException("EntityMixin application failed");}
|
||||
|
||||
@Shadow public abstract void onPassengerTurned(Entity $$0);
|
||||
|
||||
@ModifyExpressionValue(method = "startRiding(Lnet/minecraft/world/entity/Entity;ZZ)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityType;canSerialize()Z"))
|
||||
/*
|
||||
@ModifyExpressionValue(method = "startRiding(Lnet/minecraft/world/entity/Entity;Z)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityType;canSerialize()Z"))
|
||||
private boolean onStartRidingCheck(boolean original, Entity entity, boolean force) {
|
||||
if (force && entity instanceof Player) return true;
|
||||
return original;
|
||||
}
|
||||
|
||||
@Shadow public abstract void onPassengerTurned(Entity $$0);
|
||||
}*/
|
||||
|
||||
@Inject(method = "positionRider(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Entity$MoveFunction;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onPositionPassenger(Entity entity, MoveFunction move, CallbackInfo ci)
|
||||
|
|
@ -93,7 +93,7 @@ public abstract class EntityMixin
|
|||
@Inject(method = "onPassengerTurned(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"))
|
||||
private void onPassengerTurned(Entity toUpdate, CallbackInfo ci)
|
||||
{
|
||||
if((Object)this instanceof Player thisPlayer && toUpdate instanceof Player)
|
||||
if((Object)this instanceof Player thisPlayer && toUpdate instanceof Player otherPlayer)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(thisPlayer);
|
||||
if(carry.isCarrying(CarryType.PLAYER)) {
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public class EntityRendererMixin {
|
||||
|
||||
@Inject(at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;extractRenderState(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/client/renderer/entity/state/EntityRenderState;F)V",
|
||||
shift = At.Shift.AFTER
|
||||
), method = "createRenderState(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;")
|
||||
private void onCreateRenderState(Entity entity, float $$1, CallbackInfoReturnable<EntityRenderState> cir, @Local(ordinal = 0) EntityRenderState state) {
|
||||
if (entity instanceof Player player) {
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
||||
ICarryOnRenderState carryOnRenderState = (ICarryOnRenderState) state;
|
||||
carryOnRenderState.setCarryOnData(carry);
|
||||
carryOnRenderState.setRenderWidth(CarryRenderHelper.getRenderWidth(player));
|
||||
|
||||
carryOnRenderState.setPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,8 @@ package tschipp.carryon.mixin;
|
|||
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
|
@ -31,8 +32,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
import tschipp.carryon.common.scripting.CarryOnScript.ScriptRender;
|
||||
|
||||
@Mixin(HumanoidModel.class)
|
||||
|
|
@ -44,20 +46,20 @@ public class HumanoidModelMixin {
|
|||
@Shadow
|
||||
public ModelPart leftArm;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)V")
|
||||
private void onSetupAnimations(HumanoidRenderState state, CallbackInfo ci)
|
||||
@Inject(at = @At("RETURN"), method = "setupAnim(Lnet/minecraft/world/entity/LivingEntity;FFFFF)V")
|
||||
private void onSetupAnimations(LivingEntity living, float f1, float f2, float f3, float f4, float f5, CallbackInfo ci)
|
||||
{
|
||||
if(state instanceof ICarryOnRenderState carryOnRenderState && Constants.CLIENT_CONFIG.renderArms)
|
||||
if(living instanceof Player player && Constants.CLIENT_CONFIG.renderArms)
|
||||
{
|
||||
CarryOnData carry = carryOnRenderState.getCarryOnData();
|
||||
if(carry != null && carry.isCarrying() && !state.isVisuallySwimming && !state.isFallFlying)
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying() && !player.isVisuallySwimming() && !player.isFallFlying())
|
||||
{
|
||||
boolean sneaking = state.isCrouching;
|
||||
boolean sneaking = !player.getAbilities().flying && player.isShiftKeyDown() || player.isCrouching();
|
||||
|
||||
float x = 1.0f + (sneaking ? 0.2f : 0.0f) + (carry.isCarrying(CarryOnData.CarryType.BLOCK) ? 0.0f : 0.3f);
|
||||
float z = 0.05f;
|
||||
|
||||
float width = carryOnRenderState.getRenderWidth();
|
||||
float width = CarryRenderHelper.getRenderWidth(player);
|
||||
float offset = Math.min((width - 1) / 1.5f, 0.2f);
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ 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.CallbackInfo;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mixin(Inventory.class)
|
||||
|
|
@ -62,7 +61,7 @@ public class InventoryMixin
|
|||
return original.call(instance, slot);
|
||||
}
|
||||
|
||||
@Inject(method = "addAndPickItem(Lnet/minecraft/world/item/ItemStack;)V", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "setPickedItem(Lnet/minecraft/world/item/ItemStack;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onPickBlock(CallbackInfo info)
|
||||
{
|
||||
if(CarryOnDataManager.getCarryData(player).isCarrying())
|
||||
|
|
@ -76,11 +75,10 @@ public class InventoryMixin
|
|||
info.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "setSelectedSlot(I)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSwapPaint(int slot, CallbackInfo info)
|
||||
@Inject(method = "swapPaint(D)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSwapPaint(double direction, CallbackInfo info)
|
||||
{
|
||||
CarryOnData data = CarryOnDataManager.getCarryData(player);
|
||||
if(data.isCarrying() && data.getSelected() != slot)
|
||||
if(CarryOnDataManager.getCarryData(player).isCarrying())
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,24 +28,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
|
||||
@WrapWithCondition(
|
||||
method = "handleKeybinds()V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Inventory;setSelectedSlot(I)V",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
private boolean allowSlotSelection(Inventory inv, int slot) {
|
||||
boolean carrying = CarryOnDataManager.getCarryData(inv.player).isCarrying();
|
||||
|
||||
// Allow if not carrying
|
||||
if (!carrying) return true;
|
||||
|
||||
// Block only if trying to switch away
|
||||
return inv.getSelectedSlot() == slot;
|
||||
}
|
||||
public class MinecraftMixin
|
||||
{
|
||||
@WrapWithCondition(method = "handleKeybinds()V", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Inventory;selected:I", ordinal = 0, opcode = 181)) //Opcode for PUTFIELD
|
||||
private boolean allowSlotSelection(Inventory inv,int slot)
|
||||
{
|
||||
return !CarryOnDataManager.getCarryData(inv.player).isCarrying();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,19 +20,18 @@
|
|||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
import java.util.Optional;
|
||||
|
|
@ -44,25 +43,11 @@ public abstract class PlayerMixin extends LivingEntity {
|
|||
super(type, level);
|
||||
}
|
||||
|
||||
//We leave this in here to ensure cross-compatibility if world are upgraded from <1.21.8. Should be removed in the future.
|
||||
@Inject(method = "readAdditionalSaveData(Lnet/minecraft/world/level/storage/ValueInput;)V", at = @At("RETURN"))
|
||||
private void onReadAdditionalSaveData(ValueInput input, CallbackInfo ci)
|
||||
@Inject(method = "readAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("RETURN"))
|
||||
private void onReadAdditionalSaveData(CompoundTag tag, CallbackInfo info)
|
||||
{
|
||||
Optional<CarryOnData> res = input.read("CarryOnData", CarryOnData.CODEC);
|
||||
Optional<CarryOnData> res = CarryOnData.CODEC.parse(NbtOps.INSTANCE, tag.get(CarryOnData.SERIALIZATION_KEY)).result();
|
||||
res.ifPresent(data -> CarryOnDataManager.setCarryData((Player)((Object)this), data));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stopRiding() {
|
||||
Entity entity = this.getVehicle();
|
||||
if (entity instanceof Player && entity.getPassengers().size() < 2){
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData((Player) entity);
|
||||
if (carry.getType() == CarryType.PLAYER){
|
||||
carry.clear();
|
||||
((Player) entity).removeEffect(MobEffects.SLOWNESS);
|
||||
}
|
||||
}
|
||||
super.stopRiding();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import tschipp.carryon.client.render.ICarryOnRenderState;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
@Mixin(HumanoidRenderState.class)
|
||||
public class PlayerRenderStateMixin implements ICarryOnRenderState {
|
||||
|
||||
@Unique
|
||||
public CarryOnData carryOnData = null;
|
||||
|
||||
@Unique
|
||||
public float renderWidth = 0f;
|
||||
|
||||
|
||||
@Unique
|
||||
public Player player = null;
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public CarryOnData getCarryOnData() {
|
||||
return carryOnData;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public void setCarryOnData(CarryOnData data) {
|
||||
carryOnData = data;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public float getRenderWidth() {
|
||||
return renderWidth;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public void setRenderWidth(float val) {
|
||||
renderWidth = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ public record ClientboundStartRidingOtherPlayerPacket(int mount, int rider, bool
|
|||
|
||||
if(mount != null && rider != null)
|
||||
if(ride)
|
||||
rider.startRiding(mount, true,true);
|
||||
rider.startRiding(mount, true);
|
||||
else
|
||||
rider.stopRiding();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package tschipp.carryon.networking;
|
||||
package tschipp.carryon.networking.clientbound;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
|
|
@ -9,6 +9,7 @@ import net.minecraft.world.entity.player.Player;
|
|||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
|
||||
public record ClientboundSyncCarryDataPacket(int iden, CarryOnData data) implements PacketBase {
|
||||
|
||||
|
|
@ -24,6 +25,7 @@ public record ClientboundSyncCarryDataPacket(int iden, CarryOnData data) impleme
|
|||
public void handle(Player player) {
|
||||
Entity e = player.level().getEntity(this.iden);
|
||||
if(e instanceof Player p) {
|
||||
p.getInventory().selected = data.getSelected();
|
||||
CarryOnDataManager.setCarryData(p, data);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ package tschipp.carryon.platform.services;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -63,11 +63,11 @@ public interface IPlatformHelper {
|
|||
|
||||
<T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args);
|
||||
|
||||
void sendPacketToServer(Identifier id, PacketBase packet);
|
||||
void sendPacketToServer(ResourceLocation id, PacketBase packet);
|
||||
|
||||
void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player);
|
||||
void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player);
|
||||
|
||||
default void sendPacketToAllPlayers(Identifier id, PacketBase packet, ServerLevel level) {
|
||||
default void sendPacketToAllPlayers(ResourceLocation id, PacketBase packet, ServerLevel level) {
|
||||
for(ServerPlayer p : level.players())
|
||||
sendPacketToPlayer(id, packet, p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Benutzerdefinierte Bedingungen für Entitäten",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʎʇᴉʇuƎ ɯoʇsnƆ",
|
||||
|
||||
"key.carry.desc": "ʎɹɹɐƆ",
|
||||
"key.category.carryon.key.carry.category": "uO ʎɹɹɐƆ"
|
||||
"key.carry.category": "uO ʎɹɹɐƆ"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Custom Entity Pickup Conditions",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"carryon.category.settings": "Configuraciones",
|
||||
"carryon.category.blacklist": "Lista Negra",
|
||||
"carryon.category.modeloverrides": "Reemplazos de Modelos (Avanzado)",
|
||||
"carryon.category.custompickupconditions": "Condiciones Personalizadas de Recogida (Avanzado)",
|
||||
"carryon.category.whitelist": "Lista Blanca",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "Reemplazos de Modelos",
|
||||
"carryon.general.blacklist.forbiddenentities": "Entidades que el jugador no puede levantar",
|
||||
"carryon.general.blacklist.forbiddentiles": "Bloques que el jugador no puede levantar",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Condiciones Personalizadas de Recogida de Bloques",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Condiciones Personalizadas de Recogida de Entidades",
|
||||
|
||||
"key.carry.desc": "Cargar",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"carryon.category.settings": "Ajustes",
|
||||
"carryon.category.blacklist": "Lista Negra",
|
||||
"carryon.category.modeloverrides": "Reemplazos de Modelo (Avanzado)",
|
||||
"carryon.category.custompickupconditions": "Condiciones Personalizadas para Recoger (Avanzado)",
|
||||
"carryon.category.whitelist": "Lista Blanca",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "Reemplazos de Modelo",
|
||||
"carryon.general.blacklist.forbiddenentities": "Entidades que el jugador no puede recoger",
|
||||
"carryon.general.blacklist.forbiddentiles": "Bloques que el jugador no puede recoger",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Condiciones Personalizadas para Recoger Bloques",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Condiciones Personalizadas para Recoger Entidades",
|
||||
|
||||
"key.carry.desc": "Recoger",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Customizar condiciones para recoger entidades",
|
||||
|
||||
"key.carry.desc": "Agarrar",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Conditions de ramassage d'entités personalisés",
|
||||
|
||||
"key.carry.desc": "Saisir",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"carryon.category.settings": "Beállítások",
|
||||
"carryon.category.blacklist": "Feketelista",
|
||||
"carryon.category.modeloverrides": "Model felülírások (Fejlett)",
|
||||
"carryon.category.custompickupconditions": "Egyedi felvételi feltételek (Fejlett)",
|
||||
"carryon.category.whitelist": "Fehérlista",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "Model felülírások",
|
||||
"carryon.general.blacklist.forbiddenentities": "Entitások amiket a játékos nem vehet fel",
|
||||
"carryon.general.blacklist.forbiddentiles": "Blokkok amiket a játékos nem vehet fel",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Egyedi blokk felvételi feltételek",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Egyedi entitás felvételi feltételek",
|
||||
|
||||
"key.carry.desc": "Cipelés",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Condizioni di prelievo entità personalizzate",
|
||||
|
||||
"key.carry.desc": "Afferra",
|
||||
"key.category.carryon.key.carry.category": "Carry On Mod"
|
||||
"key.carry.category": "Carry On Mod"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "カスタムエンティティ持ち上げ条件",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "맞춤형 개체 들기 조건",
|
||||
|
||||
"key.carry.desc": "들고 나르기",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Пользовательские условия поднятия сущности",
|
||||
|
||||
"key.carry.desc": "Поднять",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -13,5 +13,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Özel Varlık Alma Durumları",
|
||||
|
||||
"key.carry.desc": "Taşı",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"carryon.category.settings": "Налаштування",
|
||||
"carryon.category.blacklist": "Чорний список",
|
||||
"carryon.category.modeloverrides": "Перевизначення моделей (Розширені)",
|
||||
"carryon.category.custompickupconditions": "Користувацькі умови підбору (Розширені)",
|
||||
"carryon.category.whitelist": "Білий список",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "Перевизначення моделей",
|
||||
"carryon.general.blacklist.forbiddenentities": "Сутності, які гравець не може підібрати",
|
||||
"carryon.general.blacklist.forbiddentiles": "Блоки, які гравець не може підібрати",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Користувацькі умови підбору блоків",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Користувацькі умови підбору сутностей",
|
||||
|
||||
"key.carry.desc": "Нести",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "自定义抱起实体条件",
|
||||
|
||||
"key.carry.desc": "抱起",
|
||||
"key.category.carryon.key.carry.category": "搬运"
|
||||
"key.carry.category": "搬运"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
"carryon.category.custompickupconditions.custompickupconditionsentities": "自訂實體拾取條件",
|
||||
|
||||
"key.carry.desc": "攜帶",
|
||||
"key.category.carryon.key.carry.category": "Carry On"
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -9,11 +9,8 @@
|
|||
"PlayerMixin"
|
||||
],
|
||||
"client": [
|
||||
"AvatarRendererMixin",
|
||||
"EntityRendererMixin",
|
||||
"HumanoidModelMixin",
|
||||
"MinecraftMixin",
|
||||
"PlayerRenderStateMixin"
|
||||
"MinecraftMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
|
@ -21,5 +18,5 @@
|
|||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "${mod_id}.refmap.json"
|
||||
"refmap": "${refmap_target}refmap.json"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "${mod_name}",
|
||||
"pack_format": 34
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,33 @@
|
|||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'idea'
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
}
|
||||
base {
|
||||
archivesName = "${mod_id}-fabric-${minecraft_version}"
|
||||
}
|
||||
|
||||
/*
|
||||
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
||||
|
||||
if (project.hasProperty('secretFile')) {
|
||||
loadSecrets(new File((String) findProperty('secretFile')))
|
||||
}
|
||||
*/
|
||||
|
||||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
version += "." + System.getenv('BUILD_NUMBER')
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Shedaniel"
|
||||
url "https://maven.shedaniel.me/"
|
||||
}
|
||||
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
maven {
|
||||
name = "Terraformers"
|
||||
url = "https://maven.terraformersmc.com/"
|
||||
url "https://maven.siphalor.de/"
|
||||
name "Siphalor's Maven"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.layered() {
|
||||
|
|
@ -28,17 +37,14 @@ dependencies {
|
|||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
||||
implementation project(":Common")
|
||||
|
||||
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
}
|
||||
modApi "com.terraformersmc:modmenu:17.0.0-beta.1"
|
||||
modRuntimeOnly "de.siphalor:amecsapi-1.20:1.5.6+mc1.20.2"
|
||||
}
|
||||
|
||||
loom {
|
||||
def aw = project(':Common').file("src/main/resources/${mod_id}.accesswidener")
|
||||
if (aw.exists()) {
|
||||
accessWidenerPath.set(aw)
|
||||
if (project(":Common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
|
||||
accessWidenerPath.set(project(":Common").file("src/main/resources/${mod_id}.accesswidener"))
|
||||
}
|
||||
mixin {
|
||||
defaultRefmapName.set("${mod_id}.refmap.json")
|
||||
|
|
@ -58,3 +64,31 @@ loom {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
tasks.withType(Javadoc).configureEach {
|
||||
source(project(":Common").sourceSets.main.allJava)
|
||||
}
|
||||
tasks.named("sourcesJar", Jar) {
|
||||
from(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
processResources {
|
||||
from project(":Common").sourceSets.main.resources
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifactId base.archivesName.get()
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import net.fabricmc.api.ModInitializer;
|
|||
import net.fabricmc.fabric.api.attachment.v1.AttachmentRegistry;
|
||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
import tschipp.carryon.events.CommonEvents;
|
||||
|
|
@ -34,22 +33,20 @@ import java.io.IOException;
|
|||
|
||||
public class CarryOnFabricMod implements ModInitializer {
|
||||
|
||||
public static final AttachmentType<CarryOnData> CARRY_ON_DATA_ATTACHMENT_TYPE = AttachmentRegistry.create(
|
||||
Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"),
|
||||
/* public static final AttachmentType<CarryOnData> CARRY_ON_DATA_ATTACHMENT_TYPE = AttachmentRegistry.create(
|
||||
ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"),
|
||||
builder -> builder
|
||||
.initializer(() -> new CarryOnData(new CompoundTag()))
|
||||
.persistent(CarryOnData.CODEC)
|
||||
.syncWith(CarryOnData.STREAM_CODEC, (t, p) ->{
|
||||
ServerPlayer player = (ServerPlayer) t;
|
||||
// the isAlive check avoids us syncing attachment data about dead players. Which causes a disconnect
|
||||
// player.tickCount > 0 avoids us syncing attachment data about players the instant they spawn.
|
||||
// Which also causes a disconnect as the player entity may not be synced yet.
|
||||
return p.connection != null && player.isAlive() && !p.isRemoved() && player.tickCount > 0;
|
||||
})
|
||||
.syncWith(CarryOnData.STREAM_CODEC, (t, p) -> p.connection != null)
|
||||
.copyOnDeath()
|
||||
|
||||
|
||||
); */
|
||||
|
||||
);
|
||||
public static final AttachmentType<CarryOnData> CARRY_ON_DATA_ATTACHMENT_TYPE = AttachmentRegistry.<CarryOnData>builder()
|
||||
.initializer(() -> new CarryOnData(new CompoundTag()))
|
||||
.persistent(CarryOnData.CODEC)
|
||||
.buildAndRegister(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"));
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ public class ArchitecturyCompat {
|
|||
private static Method PLACE_BLOCK;
|
||||
private static Method IS_FALSE;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void setup( ) {
|
||||
try {
|
||||
Class BlockEvent = Class.forName("dev.architectury.event.events.common.BlockEvent");
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
package tschipp.carryon.compat;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
|
||||
public class ClothConfigCompatFabric {
|
||||
|
||||
public static Screen createScreen(BuiltConfig client, BuiltConfig common, Screen screen) {
|
||||
|
||||
return ClothConfigCompat.getConfigScreen(client, common, screen, ConfigLoaderImpl::saveConfigs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
package tschipp.carryon.compat;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
|
||||
public class ModMenuCompat implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
|
||||
BuiltConfig[] configs = ConfigLoaderImpl.CONFIGS.values().toArray(new BuiltConfig[0]);
|
||||
|
||||
return (parent) -> ClothConfigCompatFabric.createScreen(configs[1], configs[0], parent);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ package tschipp.carryon.config.fabric;
|
|||
import com.google.gson.*;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import tschipp.carryon.common.config.ListHandler;
|
||||
import tschipp.carryon.config.*;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -31,7 +30,7 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ public class ConfigLoaderImpl {
|
|||
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
|
||||
|
||||
//Default JSON and config data.
|
||||
public static final Map<JsonObject, BuiltConfig> CONFIGS = new LinkedHashMap<>();
|
||||
public static final Map<JsonObject, BuiltConfig> CONFIGS = new HashMap<>();
|
||||
|
||||
public static void initialize() throws IOException {
|
||||
Path cfgPath = FabricLoader.getInstance().getConfigDir();
|
||||
|
|
@ -69,11 +68,11 @@ public class ConfigLoaderImpl {
|
|||
JsonElement value = entry.getValue();
|
||||
if (value instanceof JsonPrimitive configValue) {
|
||||
category.getProperty(id).ifPresent(data -> {
|
||||
if (configValue.isBoolean() && data.getData().type().equals(PropertyType.BOOLEAN))
|
||||
if (configValue.isBoolean() && data.data().type().equals(PropertyType.BOOLEAN))
|
||||
data.setBoolean(configValue.getAsBoolean());
|
||||
if (configValue.isNumber() && data.getData().type().equals(PropertyType.INT)) {
|
||||
if (configValue.isNumber() && data.data().type().equals(PropertyType.INT)) {
|
||||
int configInt = configValue.getAsInt();
|
||||
if (configInt > data.getData().max() || configInt < data.getData().min()) {
|
||||
if (configInt > data.data().max() || configInt < data.data().min()) {
|
||||
try {
|
||||
config.addProperty(id, data.getInt());
|
||||
} catch (IllegalAccessException ignored) {
|
||||
|
|
@ -82,9 +81,9 @@ public class ConfigLoaderImpl {
|
|||
data.setInt(configInt);
|
||||
}
|
||||
}
|
||||
if (configValue.isNumber() && data.getData().type().equals(PropertyType.DOUBLE)) {
|
||||
if (configValue.isNumber() && data.data().type().equals(PropertyType.DOUBLE)) {
|
||||
double configDouble = configValue.getAsDouble();
|
||||
if (configDouble > data.getData().maxD() || configDouble < data.getData().minD()) {
|
||||
if (configDouble > data.data().maxD() || configDouble < data.data().minD()) {
|
||||
try {
|
||||
config.addProperty(id, data.getDouble());
|
||||
} catch (IllegalAccessException ignored) {
|
||||
|
|
@ -98,7 +97,7 @@ public class ConfigLoaderImpl {
|
|||
category.getCategory(id).ifPresent(cat -> loadConfig(cat, subConfig));
|
||||
} else if (value instanceof JsonArray list) {
|
||||
category.getProperty(id).ifPresent(data -> {
|
||||
if(data.getData().type() == PropertyType.STRING_ARRAY)
|
||||
if(data.data().type() == PropertyType.STRING_ARRAY)
|
||||
{
|
||||
List<String> ls = new ArrayList<>();
|
||||
for(JsonElement arrEle : list)
|
||||
|
|
@ -117,20 +116,6 @@ public class ConfigLoaderImpl {
|
|||
return config;
|
||||
}
|
||||
|
||||
public static void saveConfigs() {
|
||||
try {
|
||||
Path cfgPath = FabricLoader.getInstance().getConfigDir();
|
||||
for (Map.Entry<JsonObject, BuiltConfig> entry : CONFIGS.entrySet()) {
|
||||
File cfgFile = new File(cfgPath.toFile(), entry.getValue().fileName+".json");
|
||||
cfgPath.toFile().mkdirs();
|
||||
FileUtils.write(cfgFile, GSON.toJson(entry.getKey()), StandardCharsets.UTF_8);
|
||||
}
|
||||
ListHandler.initConfigLists();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerConfig(BuiltConfig config) {
|
||||
try {
|
||||
JsonObject configJson = new JsonObject();
|
||||
|
|
@ -150,39 +135,21 @@ public class ConfigLoaderImpl {
|
|||
builder.add(category.category, categoryJson);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void buildProperty(JsonObject builder, PropertyData data) throws IllegalAccessException {
|
||||
AnnotationData annotationData = data.getData();
|
||||
AnnotationData annotationData = data.data();
|
||||
builder.addProperty("//"+data.getId(), annotationData.description());
|
||||
|
||||
switch (annotationData.type()) {
|
||||
case BOOLEAN:
|
||||
builder.addProperty(data.getId(), data.getBoolean());
|
||||
data.setSetter((b) -> {builder.addProperty(data.getId(), (boolean)b); data.setBoolean((boolean)b);});
|
||||
break;
|
||||
case INT:
|
||||
builder.addProperty(data.getId(), data.getInt());
|
||||
data.setSetter((b) -> {builder.addProperty(data.getId(), (int)b); data.setInt((int)b);});
|
||||
break;
|
||||
case DOUBLE:
|
||||
builder.addProperty(data.getId(), data.getDouble());
|
||||
data.setSetter((b) -> {builder.addProperty(data.getId(), (double)b); data.setDouble((double)b);});
|
||||
break;
|
||||
case STRING_ARRAY:
|
||||
case BOOLEAN -> builder.addProperty(data.getId(), data.getBoolean());
|
||||
case INT -> builder.addProperty(data.getId(), data.getInt());
|
||||
case DOUBLE -> builder.addProperty(data.getId(), data.getDouble());
|
||||
case STRING_ARRAY -> {
|
||||
JsonArray arr = new JsonArray();
|
||||
for(String s : data.getStringArray())
|
||||
arr.add(s);
|
||||
builder.add(data.getId(), arr);
|
||||
data.setSetter(list -> {
|
||||
JsonArray overwrite = new JsonArray();
|
||||
for(String s : (List<String>)list)
|
||||
overwrite.add(s);
|
||||
builder.add(data.getId(), overwrite);
|
||||
data.setStringArray(((List<?>) list).toArray(new String[0]));
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new IllegalAccessException("Unknown property type.");
|
||||
}
|
||||
default -> throw new IllegalAccessException("Unknown property type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
|||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.player.*;
|
||||
import net.fabricmc.fabric.api.networking.v1.EntityTrackingEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
|
@ -35,6 +36,7 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
|
@ -43,6 +45,8 @@ import tschipp.carryon.common.carry.PlacementHandler;
|
|||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
import tschipp.carryon.compat.ArchitecturyCompat;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
import tschipp.carryon.scripting.IdentifiableScriptReloadListener;
|
||||
|
||||
public class CommonEvents {
|
||||
|
|
@ -56,7 +60,7 @@ public class CommonEvents {
|
|||
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
||||
|
||||
if(world.isClientSide())
|
||||
if(world.isClientSide)
|
||||
return InteractionResult.PASS;
|
||||
|
||||
BlockPos pos = hitResult.getBlockPos();
|
||||
|
|
@ -97,7 +101,7 @@ public class CommonEvents {
|
|||
|
||||
UseEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
|
||||
|
||||
if(level.isClientSide())
|
||||
if(level.isClientSide)
|
||||
return InteractionResult.PASS;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
|
@ -133,10 +137,12 @@ public class CommonEvents {
|
|||
CarryOnCommon.onCarryTick(player);
|
||||
});
|
||||
|
||||
|
||||
ServerPlayerEvents.COPY_FROM.register(((oldPlayer, newPlayer, alive) -> {
|
||||
PlacementHandler.placeCarriedOnDeath(oldPlayer, newPlayer, !alive);
|
||||
}));
|
||||
|
||||
|
||||
PlayerBlockBreakEvents.BEFORE.register(((world, player, pos, state, blockEntity) -> {
|
||||
if(!CarryOnCommon.onTryBreakBlock(player))
|
||||
return false;
|
||||
|
|
@ -159,6 +165,18 @@ public class CommonEvents {
|
|||
CarryOnCommon.onRiderDisconnected(handler.getPlayer());
|
||||
});
|
||||
|
||||
EntityTrackingEvents.START_TRACKING.register(((trackedEntity, player) -> {
|
||||
if(trackedEntity instanceof ServerPlayer sp) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), player);
|
||||
}
|
||||
}));
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||
if(handler.getPlayer() instanceof ServerPlayer sp) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), sp);
|
||||
}
|
||||
});
|
||||
|
||||
ServerLivingEntityEvents.ALLOW_DEATH.register((entity, damageSource, damageAmount) -> {
|
||||
if(entity instanceof ServerPlayer sp) {
|
||||
CarryOnCommon.onRiderDisconnected(sp);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ package tschipp.carryon.mixin;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
@ -31,14 +31,15 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
import tschipp.carryon.client.render.CarryRenderHelper;
|
||||
|
||||
@Mixin(ItemInHandRenderer.class)
|
||||
public class ItemInHandRendererMixin
|
||||
{
|
||||
@Inject(at = @At(value = "HEAD"), method = "renderArmWithItem(Lnet/minecraft/client/player/AbstractClientPlayer;FFLnet/minecraft/world/InteractionHand;FLnet/minecraft/world/item/ItemStack;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V", cancellable = true)
|
||||
private void renderArmWithItem(AbstractClientPlayer player, float partialTick, float pitch, InteractionHand hand, float swingProgress, ItemStack item, float equippedProgress, PoseStack poseStack, SubmitNodeCollector nodeCollector, int packedLight, CallbackInfo ci)
|
||||
@Inject(at = @At(value = "HEAD"), method = "renderArmWithItem(Lnet/minecraft/client/player/AbstractClientPlayer;FFLnet/minecraft/world/InteractionHand;FLnet/minecraft/world/item/ItemStack;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", cancellable = true)
|
||||
private void onRenderHand(AbstractClientPlayer player, float partialTicks, float pitch, InteractionHand hand, float pSwingProgress, ItemStack pStack, float pEquippedProgress, PoseStack poseStack, MultiBufferSource buffer, int light, CallbackInfo ci)
|
||||
{
|
||||
if(CarriedObjectRender.draw(player, poseStack, packedLight, partialTick,nodeCollector,true))
|
||||
if(CarryRenderHelper.getPerspective() == 0 && CarriedObjectRender.drawFirstPerson(player, buffer, poseStack, light, partialTicks))
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* GNU Lesser General Public License v3
|
||||
* Copyright (C) 2024 Tschipp
|
||||
* mrtschipp@gmail.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class LevelRendererMixin
|
||||
{
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;F)V"), method = "renderLevel(Lnet/minecraft/client/DeltaTracker;ZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V")
|
||||
private void onRenderLevel(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix, CallbackInfo ci, @Local PoseStack poseStack)
|
||||
{
|
||||
CarriedObjectRender.drawThirdPerson(deltaTracker.getGameTimeDeltaPartialTick(true), poseStack.last().pose());
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
package tschipp.carryon.mixin;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -36,13 +35,13 @@ import tschipp.carryon.common.carry.PlacementHandler;
|
|||
@Mixin(Player.class)
|
||||
public class PlayerMixinFabric
|
||||
{
|
||||
@Inject(at = @At("HEAD"), method = "hurtServer(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)Z")
|
||||
private void onHurt(ServerLevel level, DamageSource damageSource, float amount, CallbackInfoReturnable<Boolean> cir) {
|
||||
@Inject(at = @At("HEAD"), method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")
|
||||
private void onHurt(DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(Constants.COMMON_CONFIG.settings.dropCarriedWhenHit)
|
||||
{
|
||||
Player player = ((Player)(Object)this);
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying())
|
||||
if(carry.isCarrying() && !player.level().isClientSide)
|
||||
PlacementHandler.placeCarried((ServerPlayer)player);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,9 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
@Mixin(Screen.class)
|
||||
public class ScreenMixin
|
||||
{
|
||||
@Inject(at = @At(value = "TAIL"), method = "init(II)V")
|
||||
private void onInit(int width, int height, CallbackInfo ci)
|
||||
@Inject(at = @At(value = "TAIL"), method = "init(Lnet/minecraft/client/Minecraft;II)V")
|
||||
private void onInit(Minecraft mc, int i, int j, CallbackInfo ci)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if((Object)this instanceof AbstractContainerScreen && player != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,15 +27,18 @@ import net.minecraft.network.FriendlyByteBuf;
|
|||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import tschipp.carryon.CarryOnFabricClientMod;
|
||||
import tschipp.carryon.CarryOnFabricMod;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.fabric.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
|
@ -64,7 +67,6 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
ConfigLoaderImpl.registerConfig(cfg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||
{
|
||||
|
|
@ -77,7 +79,6 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||
{
|
||||
|
|
@ -90,13 +91,13 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToServer(Identifier id, PacketBase packet)
|
||||
public void sendPacketToServer(ResourceLocation id, PacketBase packet)
|
||||
{
|
||||
CarryOnFabricClientMod.sendPacketToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player)
|
||||
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player)
|
||||
{
|
||||
ServerPlayNetworking.send(player, packet);
|
||||
}
|
||||
|
|
@ -110,5 +111,8 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
|||
@Override
|
||||
public void setCarryData(Player player, CarryOnData data) {
|
||||
player.setAttached(CarryOnFabricMod.CARRY_ON_DATA_ATTACHMENT_TYPE, data);
|
||||
if(!player.level().isClientSide) {
|
||||
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@
|
|||
package tschipp.carryon.scripting;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
|
||||
public class IdentifiableScriptReloadListener extends ScriptReloadListener implements IdentifiableResourceReloadListener
|
||||
{
|
||||
@Override
|
||||
public Identifier getFabricId()
|
||||
public ResourceLocation getFabricId()
|
||||
{
|
||||
return Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carryon_scripts");
|
||||
return ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carryon_scripts");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
],
|
||||
"client": [
|
||||
"ItemInHandRendererMixin",
|
||||
"ScreenMixin"
|
||||
"LevelRendererMixin",
|
||||
"ScreenMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@
|
|||
],
|
||||
"client": [
|
||||
"tschipp.carryon.CarryOnFabricClientMod"
|
||||
],
|
||||
"modmenu" : [
|
||||
"tschipp.carryon.compat.ModMenuCompat"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
|
@ -36,8 +33,8 @@
|
|||
"depends": {
|
||||
"fabricloader": ">=${fabric_loader_version}",
|
||||
"fabric-api": "*",
|
||||
"minecraft": "${minecraft_version_range_fabric}",
|
||||
"java": ">=${java_version}"
|
||||
"minecraft": "${minecraft_version}",
|
||||
"java": ">=21"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,10 +1,26 @@
|
|||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.46,6.2)'
|
||||
id 'idea'
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
||||
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
|
||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
||||
}
|
||||
|
||||
/*
|
||||
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
||||
|
||||
if (project.hasProperty('secretFile')) {
|
||||
loadSecrets(new File((String) findProperty('secretFile')))
|
||||
}
|
||||
|
||||
*/
|
||||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
version += "." + System.getenv('BUILD_NUMBER')
|
||||
}
|
||||
|
||||
|
||||
|
||||
base {
|
||||
archivesName = "${mod_id}-forge-${minecraft_version}"
|
||||
}
|
||||
|
|
@ -16,25 +32,16 @@ mixin {
|
|||
config "${mod_id}.forge.mixins.json"
|
||||
}
|
||||
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
"MixinConfigs" : "${mod_id}.mixins.json,${mod_id}.forge.mixins.json"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
jarJar.enable()
|
||||
build.dependsOn tasks.jarJar
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'parchment', version: parchment_mappings
|
||||
mappings channel: 'parchment', version: "${parchment_mappings}"
|
||||
copyIdeResources = true
|
||||
reobf = false
|
||||
|
||||
def at = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
accessTransformer = at
|
||||
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
}
|
||||
|
||||
runs {
|
||||
|
|
@ -44,7 +51,6 @@ minecraft {
|
|||
taskName 'Client'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
property 'eventbus.api.strictRuntimeChecks', 'true'
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
mods {
|
||||
modClientRun {
|
||||
|
|
@ -60,7 +66,6 @@ minecraft {
|
|||
taskName 'Server'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
property 'eventbus.api.strictRuntimeChecks', 'true'
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
mods {
|
||||
modServerRun {
|
||||
|
|
@ -77,7 +82,6 @@ minecraft {
|
|||
taskName 'Data'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
property 'eventbus.api.strictRuntimeChecks', 'true'
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
|
||||
mods {
|
||||
modDataRun {
|
||||
|
|
@ -92,25 +96,17 @@ minecraft {
|
|||
sourceSets.main.resources.srcDir 'src/generated/resources'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Shedaniel"
|
||||
url "https://maven.shedaniel.me/"
|
||||
}
|
||||
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
compileOnly project(":Common")
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.5-SNAPSHOT:processor'
|
||||
annotationProcessor 'net.minecraftforge:eventbus-validator:7.0-beta.7'
|
||||
// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||
|
||||
|
|
@ -121,8 +117,6 @@ dependencies {
|
|||
|
||||
//implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
|
||||
|
||||
compileOnly(fg.deobf("me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"))
|
||||
|
||||
fileTree("libs").matching {
|
||||
include "*.jar"
|
||||
}.each {
|
||||
|
|
@ -136,14 +130,47 @@ dependencies {
|
|||
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
tasks.withType(Javadoc).configureEach {
|
||||
source(project(":Common").sourceSets.main.allJava)
|
||||
}
|
||||
tasks.named("sourcesJar", Jar) {
|
||||
from(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
processResources {
|
||||
from project(":Common").sourceSets.main.resources
|
||||
}
|
||||
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
"MixinConfigs" : "${mod_id}.mixins.json,${mod_id}.forge.mixins.json"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifactId base.archivesName.get()
|
||||
from components.java
|
||||
fg.component(it)
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge the resources and classes into the same directory.
|
||||
// This is done because java expects modules to be in a single directory.
|
||||
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
|
||||
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
|
||||
sourceSets.each {
|
||||
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
||||
it.output.resourcesDir = dir
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
package tschipp.carryon;
|
||||
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
|
@ -29,8 +28,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|||
import net.minecraftforge.network.ChannelBuilder;
|
||||
import net.minecraftforge.network.SimpleChannel;
|
||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mod(Constants.MOD_ID)
|
||||
@EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
|
|
@ -38,7 +35,7 @@ public class CarryOnForge {
|
|||
|
||||
public static SimpleChannel network;
|
||||
|
||||
public CarryOnForge(FMLJavaModLoadingContext context) {
|
||||
public CarryOnForge() {
|
||||
|
||||
// This method is invoked by the Forge mod loader when it is ready
|
||||
// to load your mod. You can access Forge and Common code in this
|
||||
|
|
@ -46,23 +43,17 @@ public class CarryOnForge {
|
|||
// Use Forge to bootstrap the Common mod.
|
||||
CarryOnCommon.registerConfig();
|
||||
|
||||
ConfigLoaderImpl.initialize(context);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
|
||||
ConfigLoaderImpl.initialize();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void setup(final FMLCommonSetupEvent event)
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
network = ChannelBuilder.named(Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carryonpackets")).simpleChannel();
|
||||
network = ChannelBuilder.named(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carryonpackets")).simpleChannel();
|
||||
|
||||
CarryOnCommon.registerServerPackets();
|
||||
CarryOnCommon.registerClientPackets();
|
||||
|
||||
Services.PLATFORM.registerClientboundPacket(
|
||||
ClientboundSyncCarryDataPacket.TYPE,
|
||||
ClientboundSyncCarryDataPacket.class,
|
||||
ClientboundSyncCarryDataPacket.CODEC,
|
||||
ClientboundSyncCarryDataPacket::handle
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,13 +23,12 @@ package tschipp.carryon.config.forge;
|
|||
import com.electronwill.nightconfig.core.AbstractConfig;
|
||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.config.IConfigSpec;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.config.AnnotationData;
|
||||
import tschipp.carryon.config.BuiltCategory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
|
|
@ -37,28 +36,46 @@ import tschipp.carryon.config.PropertyData;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = Constants.MOD_ID)
|
||||
public class ConfigLoaderImpl {
|
||||
|
||||
public static final Map<ForgeConfigSpec, BuiltConfig> CONFIGS = new HashMap<>();
|
||||
|
||||
public static void initialize(FMLJavaModLoadingContext context) {
|
||||
public static void initialize() {
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
bus.addListener(ConfigLoaderImpl::onConfigLoad);
|
||||
bus.addListener(ConfigLoaderImpl::onConfigReload);
|
||||
|
||||
ConfigLoaderImpl.CONFIGS.forEach((spec, config) -> {
|
||||
if(config.fileName.contains("client"))
|
||||
context.registerConfig(ModConfig.Type.CLIENT, spec, config.fileName+".toml");
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec, config.fileName+".toml");
|
||||
else
|
||||
context.registerConfig(ModConfig.Type.COMMON, spec, config.fileName+".toml");
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, spec, config.fileName+".toml");
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onConfigLoad(ModConfigEvent.Loading loading) {
|
||||
loadConfig(loading.getConfig().getSpec());
|
||||
|
||||
//
|
||||
// DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||
// });
|
||||
//
|
||||
// DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||
// });
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onConfigReload(ModConfigEvent.Reloading loading) {
|
||||
loadConfig(loading.getConfig().getSpec());
|
||||
//
|
||||
// DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||
// });
|
||||
//
|
||||
// DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||
// });
|
||||
}
|
||||
|
||||
private static void loadConfig(IConfigSpec<ForgeConfigSpec> spec) {
|
||||
|
|
@ -86,15 +103,6 @@ public class ConfigLoaderImpl {
|
|||
});
|
||||
}
|
||||
|
||||
public static void saveConfig(BuiltConfig cfg) {
|
||||
for (Map.Entry<ForgeConfigSpec, BuiltConfig> entry : CONFIGS.entrySet()) {
|
||||
if(entry.getValue() == cfg) {
|
||||
ForgeConfigSpec spec = entry.getKey();
|
||||
spec.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerConfig(BuiltConfig config) {
|
||||
try {
|
||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||
|
|
@ -114,12 +122,11 @@ public class ConfigLoaderImpl {
|
|||
builder.pop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void buildProperty(ForgeConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
||||
AnnotationData annotationData = data.getData();
|
||||
AnnotationData annotationData = data.data();
|
||||
builder.comment(annotationData.description());
|
||||
|
||||
ForgeConfigSpec.ConfigValue val = switch (annotationData.type()) {
|
||||
switch (annotationData.type()) {
|
||||
case BOOLEAN -> builder.define(data.getId(), data.getBoolean());
|
||||
case INT -> builder.defineInRange(data.getId(), data.getInt(), annotationData.min(), annotationData.max());
|
||||
case DOUBLE -> builder.defineInRange(data.getId(), data.getDouble(), annotationData.minD(), annotationData.maxD());
|
||||
|
|
@ -132,8 +139,6 @@ public class ConfigLoaderImpl {
|
|||
return new ArrayList<>();
|
||||
}, obj -> obj instanceof String);
|
||||
default -> throw new IllegalAccessException("Unknown property type.");
|
||||
};
|
||||
|
||||
data.setSetter(val::set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,15 @@ package tschipp.carryon.events;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent.Stage;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -42,37 +44,47 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
public class ClientEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static boolean renderHand(RenderHandEvent event)
|
||||
public static void renderHand(RenderHandEvent event)
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
MultiBufferSource buffer = event.getMultiBufferSource();
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
int light = event.getPackedLight();
|
||||
float partialTicks = event.getPartialTick();
|
||||
SubmitNodeCollector nodes =event.getNodeCollector();
|
||||
//If true, cancels event
|
||||
return CarriedObjectRender.draw(player, matrix, light, partialTicks,nodes,true) && CarryRenderHelper.getPerspective() == 0;
|
||||
}
|
||||
|
||||
if(CarriedObjectRender.drawFirstPerson(player, buffer, matrix, light, partialTicks) && CarryRenderHelper.getPerspective() == 0)
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static boolean onGuiInit(ScreenEvent.Init.Pre event)
|
||||
public static void onRenderLevel(RenderLevelStageEvent event)
|
||||
{
|
||||
boolean inventory = event.getScreen() instanceof AbstractContainerScreen;
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if(event.getStage() == Stage.AFTER_PARTICLES)
|
||||
CarriedObjectRender.drawThirdPerson(Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(true), event.getPoseStack());
|
||||
}
|
||||
|
||||
if (player != null && inventory)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (carry.isCarrying())
|
||||
{
|
||||
mc.player.closeContainer();
|
||||
mc.screen = null;
|
||||
mc.mouseHandler.grabMouse();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onGuiInit(ScreenEvent.Init.Pre event)
|
||||
{
|
||||
if (event.getScreen() != null)
|
||||
{
|
||||
boolean inventory = event.getScreen() instanceof AbstractContainerScreen;
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
|
||||
if (player != null && inventory)
|
||||
{
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (carry.isCarrying())
|
||||
{
|
||||
mc.player.closeContainer();
|
||||
mc.screen = null;
|
||||
mc.mouseHandler.grabMouse();
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClientTick(ClientTickEvent.Post event)
|
||||
|
|
|
|||
|
|
@ -21,17 +21,17 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.Result;
|
||||
import net.minecraftforge.event.*;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
||||
|
|
@ -46,8 +46,10 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent.BreakEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent;
|
||||
import net.minecraftforge.eventbus.api.listener.Priority;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -59,29 +61,33 @@ import tschipp.carryon.common.carry.PickupHandler;
|
|||
import tschipp.carryon.common.carry.PlacementHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID)
|
||||
public class CommonEvents
|
||||
{
|
||||
@SubscribeEvent(priority = Priority.HIGH)
|
||||
public static boolean onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
Player player = event.getEntity();
|
||||
Level level = event.getLevel();
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
if (level.isClientSide())
|
||||
return false;
|
||||
if (level.isClientSide)
|
||||
return;
|
||||
|
||||
boolean success = false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (!carry.isCarrying()) {
|
||||
if (PickupHandler.tryPickUpBlock((ServerPlayer) player, pos, level, (pState, pPos) -> {
|
||||
BlockEvent.BreakEvent breakEvent = new BreakEvent(level, pPos, pState, player, Result.DEFAULT);
|
||||
return !BreakEvent.BUS.post(breakEvent);
|
||||
BlockEvent.BreakEvent breakEvent = new BreakEvent(level, pPos, pState, player);
|
||||
MinecraftForge.EVENT_BUS.post(breakEvent);
|
||||
return !breakEvent.isCanceled();
|
||||
})) {
|
||||
success = true;
|
||||
}
|
||||
|
|
@ -90,13 +96,15 @@ public class CommonEvents
|
|||
PlacementHandler.tryPlaceBlock((ServerPlayer) player, pos, event.getFace(), (pos2, state) -> {
|
||||
BlockSnapshot snapshot = BlockSnapshot.create(level.dimension(), level, pos2);
|
||||
EntityPlaceEvent event1 = new EntityPlaceEvent(snapshot, level.getBlockState(pos), player);
|
||||
return !EntityPlaceEvent.BUS.post(event1);
|
||||
MinecraftForge.EVENT_BUS.post(event1);
|
||||
return !event1.isCanceled();
|
||||
});
|
||||
} else {
|
||||
PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> {
|
||||
if (toPlace instanceof Mob mob) {
|
||||
FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, ((ServerLevelAccessor) level).getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), EntitySpawnReason.EVENT, null, null, null);
|
||||
return !FinalizeSpawn.BUS.post(checkSpawn);
|
||||
FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, level.getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), MobSpawnType.EVENT, null, null, null);
|
||||
MinecraftForge.EVENT_BUS.post(checkSpawn);
|
||||
return event.getResult() != Result.DENY;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
@ -105,38 +113,40 @@ public class CommonEvents
|
|||
}
|
||||
|
||||
if (success) {
|
||||
event.setUseBlock(Result.DENY);
|
||||
event.setUseItem(Result.DENY);
|
||||
event.setUseBlock(Event.Result.DENY);
|
||||
event.setUseItem(Event.Result.DENY);
|
||||
event.setCancellationResult(InteractionResult.SUCCESS);
|
||||
return true;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = Priority.HIGH)
|
||||
public static boolean onEntityRightClick(PlayerInteractEvent.EntityInteract event)
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
|
||||
{
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
Player player = event.getEntity();
|
||||
Level level = event.getLevel();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (level.isClientSide())
|
||||
return false;
|
||||
if (level.isClientSide)
|
||||
return;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (!carry.isCarrying()) {
|
||||
if (PickupHandler.tryPickupEntity((ServerPlayer) player, target, (toPickup) -> {
|
||||
EntityPickupEvent pickupEvent = new EntityPickupEvent((ServerPlayer) player, toPickup);
|
||||
return !EntityPickupEvent.BUS.post(pickupEvent);
|
||||
MinecraftForge.EVENT_BUS.post(pickupEvent);
|
||||
return !pickupEvent.isCanceled();
|
||||
})) {
|
||||
event.setCancellationResult(InteractionResult.SUCCESS);
|
||||
return true;
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
} else if (carry.isCarrying(CarryType.ENTITY) || carry.isCarrying(CarryType.PLAYER)) {
|
||||
PlacementHandler.tryStackEntity((ServerPlayer) player, target);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -171,14 +181,14 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
public static void onServerTick(ServerTickEvent.Post event)
|
||||
{
|
||||
for (ServerPlayer player : event.server().getPlayerList().getPlayers())
|
||||
for (ServerPlayer player : event.getServer().getPlayerList().getPlayers())
|
||||
CarryOnCommon.onCarryTick(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClone(Clone event)
|
||||
{
|
||||
if (!event.getOriginal().level().isClientSide()) {
|
||||
if (!event.getOriginal().level().isClientSide) {
|
||||
Player newPlayer = event.getEntity();
|
||||
Player oldPlayer = event.getOriginal();
|
||||
oldPlayer.reviveCaps();
|
||||
|
|
@ -198,16 +208,19 @@ public class CommonEvents
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static boolean attackEntity(AttackEntityEvent event)
|
||||
public static void attackEntity(AttackEntityEvent event)
|
||||
{
|
||||
return !CarryOnCommon.onAttackedByPlayer(event.getEntity());
|
||||
}
|
||||
if(!CarryOnCommon.onAttackedByPlayer(event.getEntity()))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static boolean onBreakBlock(BreakEvent event)
|
||||
public static void onBreakBlock(BreakEvent event)
|
||||
{
|
||||
return !CarryOnCommon.onTryBreakBlock(event.getPlayer());
|
||||
}
|
||||
if (!CarryOnCommon.onTryBreakBlock(event.getPlayer())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void playerAttack(LivingAttackEvent event)
|
||||
|
|
@ -223,9 +236,9 @@ public class CommonEvents
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onAttachCapabilities(AttachCapabilitiesEvent.Entities event) {
|
||||
if (event.getObject() instanceof Player) {
|
||||
event.addCapability(Identifier.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"), new CarryOnDataCapabilityProvider());
|
||||
public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
||||
if (event.getObject() instanceof Player player) {
|
||||
event.addCapability(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "carry_on_data"), new CarryOnDataCapabilityProvider());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,17 @@ package tschipp.carryon.events;
|
|||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public record EntityPickupEvent(ServerPlayer player, Entity target) implements Cancellable, RecordEvent {
|
||||
@Cancelable
|
||||
public class EntityPickupEvent extends Event {
|
||||
|
||||
public static final CancellableEventBus<EntityPickupEvent> BUS = CancellableEventBus.create(EntityPickupEvent.class);
|
||||
public final ServerPlayer player;
|
||||
public final Entity target;
|
||||
|
||||
public EntityPickupEvent(ServerPlayer player, Entity target) {
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@
|
|||
*/
|
||||
|
||||
package tschipp.carryon.events;
|
||||
import net.minecraftforge.eventbus.api.listener.Priority;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
|
@ -33,7 +34,7 @@ import java.util.stream.Stream;
|
|||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = Constants.MOD_ID)
|
||||
public class ModBusEvents {
|
||||
|
||||
@SubscribeEvent(priority = Priority.LOW)
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public static void serverLoad(InterModProcessEvent event)
|
||||
{
|
||||
Stream<IMCMessage> messages = InterModComms.getMessages(Constants.MOD_ID);
|
||||
|
|
|
|||
|
|
@ -22,28 +22,18 @@ package tschipp.carryon.events;
|
|||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Constants.MOD_ID, value=Dist.CLIENT)
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ModClientEvents
|
||||
{
|
||||
static{
|
||||
RegisterKeyMappingsEvent.BUS.addListener((e)->CarryOnKeybinds.registerKeybinds(e::register));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
public static void registerKeybinds(RegisterKeyMappingsEvent event)
|
||||
{
|
||||
if(Services.PLATFORM.isModLoaded("cloth_config")) {
|
||||
ConfigLoaderImpl.CONFIGS.values().toArray(new BuiltConfig[0]);
|
||||
}
|
||||
CarryOnKeybinds.registerKeybinds(event::register);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ package tschipp.carryon.platform;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -39,8 +39,8 @@ import tschipp.carryon.carry.CarryOnDataCapabilityProvider;
|
|||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.forge.ConfigLoaderImpl;
|
||||
import tschipp.carryon.networking.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
|
@ -70,7 +70,6 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
ConfigLoaderImpl.registerConfig(cfg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerServerboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||
{
|
||||
|
|
@ -87,7 +86,6 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
CarryOnForge.network.messageBuilder(clazz).codec((StreamCodec<FriendlyByteBuf, T>) codec).consumerMainThread(serverHandler).add();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends PacketBase, B extends FriendlyByteBuf> void registerClientboundPacket(CustomPacketPayload.Type<T> type, Class<T> clazz, StreamCodec<B, T> codec, BiConsumer<T, Player> handler, Object... args)
|
||||
{
|
||||
|
|
@ -106,13 +104,13 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
|
||||
|
||||
@Override
|
||||
public void sendPacketToServer(Identifier id, PacketBase packet)
|
||||
public void sendPacketToServer(ResourceLocation id, PacketBase packet)
|
||||
{
|
||||
CarryOnForge.network.send(packet, PacketDistributor.SERVER.noArg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(Identifier id, PacketBase packet, ServerPlayer player)
|
||||
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player)
|
||||
{
|
||||
CarryOnForge.network.send(packet, PacketDistributor.PLAYER.with(player));
|
||||
}
|
||||
|
|
@ -127,7 +125,7 @@ public class ForgePlatformHelper implements IPlatformHelper {
|
|||
public void setCarryData(Player player, CarryOnData data) {
|
||||
var cap = player.getCapability(CarryOnDataCapabilityProvider.CARRY_ON_DATA_CAPABILITY).orElse(new CarryOnDataCapability());
|
||||
cap.setCarryData(data);
|
||||
if(!player.level().isClientSide()) {
|
||||
if(!player.level().isClientSide) {
|
||||
sendPacketToAllPlayers(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(player.getId(), data), (ServerLevel) player.level());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
|||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="${forge_loader_version_range}" #mandatory
|
||||
versionRange="${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
|
|
|
|||
|
|
@ -11,5 +11,6 @@
|
|||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
},
|
||||
"refmap": "${refmap_target}refmap.json"
|
||||
}
|
||||
|
|
@ -1,174 +1,124 @@
|
|||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'net.neoforged.moddev'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Shedaniel"
|
||||
url "https://maven.shedaniel.me/"
|
||||
}
|
||||
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
neoForge {
|
||||
version = neoforge_version
|
||||
// Automatically enable neoforge AccessTransformers if the file exists
|
||||
def at = project(':Common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
parchment {
|
||||
minecraftVersion = parchment_game_version
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
runs {
|
||||
configureEach {
|
||||
systemProperty('neoforge.enabledGameTestNamespaces', mod_id)
|
||||
ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
|
||||
}
|
||||
client {
|
||||
client()
|
||||
}
|
||||
data {
|
||||
clientData()
|
||||
}
|
||||
server {
|
||||
server()
|
||||
}
|
||||
}
|
||||
mods {
|
||||
"${mod_id}" {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.160'
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compileOnly "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"
|
||||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
version += "." + System.getenv('BUILD_NUMBER')
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "${mod_id}-neoforge-${minecraft_version}"
|
||||
}
|
||||
|
||||
//jarJar.enable()
|
||||
|
||||
//archivesBaseName = "${mod_id}-neoforge-${minecraft_version}"
|
||||
|
||||
/*
|
||||
mixin {
|
||||
add sourceSets.main, "${mod_id}.refmap.json"
|
||||
|
||||
config "${mod_id}.mixins.json"
|
||||
config "${mod_id}.forge.mixins.json"
|
||||
}
|
||||
*/
|
||||
|
||||
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
|
||||
minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
}
|
||||
|
||||
runs {
|
||||
// applies to all the run configs below
|
||||
configureEach {
|
||||
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
||||
systemProperty 'forge.logging.console.level', 'debug'
|
||||
modSource project.sourceSets.main
|
||||
}
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
server {
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
programArgument '--nogui'
|
||||
}
|
||||
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// By default, the server will crash when no gametests are provided.
|
||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||
gameTestServer {
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
data {
|
||||
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||
// workingDirectory project.file('run-data')
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
//plugins {
|
||||
// id 'idea'
|
||||
// id 'maven-publish'
|
||||
// id 'net.neoforged.gradle.userdev' version '7.0.168'
|
||||
// id 'java-library'
|
||||
//}
|
||||
//
|
||||
//
|
||||
//if (System.getenv('BUILD_NUMBER') != null) {
|
||||
// version += "." + System.getenv('BUILD_NUMBER')
|
||||
//}
|
||||
//
|
||||
//base {
|
||||
// archivesName = "${mod_id}-neoforge-${minecraft_version}"
|
||||
//}
|
||||
//
|
||||
////jarJar.enable()
|
||||
//
|
||||
////archivesBaseName = "${mod_id}-neoforge-${minecraft_version}"
|
||||
//
|
||||
///*
|
||||
//mixin {
|
||||
// add sourceSets.main, "${mod_id}.refmap.json"
|
||||
//
|
||||
// config "${mod_id}.mixins.json"
|
||||
// config "${mod_id}.forge.mixins.json"
|
||||
//}
|
||||
//*/
|
||||
//
|
||||
//if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
|
||||
// minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
//}
|
||||
//
|
||||
//runs {
|
||||
// // applies to all the run configs below
|
||||
// configureEach {
|
||||
// systemProperty 'forge.logging.markers', 'REGISTRIES'
|
||||
// systemProperty 'forge.logging.console.level', 'debug'
|
||||
// modSource project.sourceSets.main
|
||||
// }
|
||||
//
|
||||
// client {
|
||||
// // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
// systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
// }
|
||||
//
|
||||
// server {
|
||||
// systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
// programArgument '--nogui'
|
||||
// }
|
||||
//
|
||||
// // This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// // By default, the server will crash when no gametests are provided.
|
||||
// // The gametest system is also enabled by default for other run configs under the /test command.
|
||||
// gameTestServer {
|
||||
// systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// data {
|
||||
// // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||
// // workingDirectory project.file('run-data')
|
||||
//
|
||||
// // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
// programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||
// }*/
|
||||
//}
|
||||
//
|
||||
//sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
//
|
||||
//configurations {
|
||||
// runtimeClasspath.extendsFrom localRuntime
|
||||
//}
|
||||
//
|
||||
//
|
||||
//tasks.named("test").configure {
|
||||
// enabled = false
|
||||
//}
|
||||
//
|
||||
//dependencies {
|
||||
// implementation "net.neoforged:neoforge:${neoforge_version}"
|
||||
// compileOnly project(":Common")
|
||||
//
|
||||
// api "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"
|
||||
// //implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
|
||||
// //implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.3:17.0.2")
|
||||
//}
|
||||
//
|
||||
//// NeoGradle compiles the game, but we don't want to add our common code to the game's code
|
||||
//Spec<Task> notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec<Task>
|
||||
//
|
||||
//tasks.withType(JavaCompile).matching(notNeoTask).configureEach {
|
||||
// source(project(":Common").sourceSets.main.allSource)
|
||||
//}
|
||||
//
|
||||
//tasks.withType(Javadoc).matching(notNeoTask).configureEach {
|
||||
// source(project(":Common").sourceSets.main.allJava)
|
||||
//}
|
||||
//
|
||||
//tasks.named("sourcesJar", Jar) {
|
||||
// from(project(":Common").sourceSets.main.allSource)
|
||||
//}
|
||||
//
|
||||
//tasks.withType(ProcessResources).matching(notNeoTask).configureEach {
|
||||
// from project(":Common").sourceSets.main.resources
|
||||
//}
|
||||
//
|
||||
//publishing {
|
||||
// publications {
|
||||
// mavenJava(MavenPublication) {
|
||||
// artifactId base.archivesName.get()
|
||||
// from components.java
|
||||
// }
|
||||
// }
|
||||
// repositories {
|
||||
// maven {
|
||||
// url "file://" + System.getenv("local_maven")
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
configurations {
|
||||
runtimeClasspath.extendsFrom localRuntime
|
||||
}
|
||||
|
||||
|
||||
tasks.named("test").configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "net.neoforged:neoforge:${neoforge_version}"
|
||||
compileOnly project(":Common")
|
||||
//implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
|
||||
//implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.3:17.0.2")
|
||||
}
|
||||
|
||||
// NeoGradle compiles the game, but we don't want to add our common code to the game's code
|
||||
Spec<Task> notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec<Task>
|
||||
|
||||
tasks.withType(JavaCompile).matching(notNeoTask).configureEach {
|
||||
source(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc).matching(notNeoTask).configureEach {
|
||||
source(project(":Common").sourceSets.main.allJava)
|
||||
}
|
||||
|
||||
tasks.named("sourcesJar", Jar) {
|
||||
from(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
tasks.withType(ProcessResources).matching(notNeoTask).configureEach {
|
||||
from project(":Common").sourceSets.main.resources
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifactId base.archivesName.get()
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,6 @@ import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
|||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import tschipp.carryon.carry.CarryOnDataSyncHandler;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||
|
||||
|
|
@ -43,8 +42,9 @@ public class CarryOnNeoForge {
|
|||
public static final Supplier<AttachmentType<CarryOnData>> CARRY_ON_DATA_ATTACHMENT = ATTACHMENT_TYPES.register(
|
||||
"carry_on_data",
|
||||
() -> AttachmentType.builder(() -> new CarryOnData(new CompoundTag()))
|
||||
.sync(new CarryOnDataSyncHandler())
|
||||
.serialize(CarryOnData.CODEC.fieldOf(CarryOnData.SERIALIZATION_KEY))
|
||||
//.sync(new CarryOnDataSyncHandler())
|
||||
//.serialize(CarryOnData.CODEC.fieldOf(CarryOnData.SERIALIZATION_KEY))
|
||||
.serialize(CarryOnData.CODEC)
|
||||
.build()
|
||||
);
|
||||
|
||||
|
|
@ -73,8 +73,6 @@ public class CarryOnNeoForge {
|
|||
|
||||
CarryOnCommon.registerServerPackets(registrar);
|
||||
CarryOnCommon.registerClientPackets(registrar);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,31 +3,18 @@ package tschipp.carryon;
|
|||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import net.neoforged.neoforge.client.network.ClientPacketDistributor;
|
||||
import tschipp.carryon.compat.ClothConfigCompatNeo;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import tschipp.carryon.networking.PacketBase;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod(value = Constants.MOD_ID, dist = Dist.CLIENT)
|
||||
public class CarryOnNeoForgeClient {
|
||||
|
||||
public CarryOnNeoForgeClient(ModContainer container) {
|
||||
|
||||
if(Services.PLATFORM.isModLoaded("cloth_config")) {
|
||||
|
||||
BuiltConfig[] configs = ConfigLoaderImpl.CONFIGS.values().toArray(new BuiltConfig[0]);
|
||||
|
||||
container.registerExtensionPoint(IConfigScreenFactory.class, (Supplier<IConfigScreenFactory>) () -> new ClothConfigCompatNeo(configs[1], configs[0]));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacketToServer(PacketBase packet) {
|
||||
ClientPacketDistributor.sendToServer(packet);
|
||||
PacketDistributor.sendToServer(packet);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,6 @@
|
|||
package tschipp.carryon.carry;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.neoforge.attachment.AttachmentSyncHandler;
|
||||
import net.neoforged.neoforge.attachment.IAttachmentHolder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
|
||||
/*
|
||||
public class CarryOnDataSyncHandler implements AttachmentSyncHandler<CarryOnData> {
|
||||
@Override
|
||||
public void write(RegistryFriendlyByteBuf registryFriendlyByteBuf, CarryOnData carryOnData, boolean b) {
|
||||
|
|
@ -20,12 +14,9 @@ public class CarryOnDataSyncHandler implements AttachmentSyncHandler<CarryOnData
|
|||
|
||||
@Override
|
||||
public boolean sendToPlayer(IAttachmentHolder holder, ServerPlayer to) {
|
||||
ServerPlayer player = (ServerPlayer) holder;
|
||||
// the isAlive check avoids us syncing attachment data about dead players. Which causes a disconnect
|
||||
// player.tickCount <= 0 avoids us syncing attachment data about players the instant they spawn.
|
||||
// Which also causes a disconnect as the player entity may not be synced yet.
|
||||
if (to.connection == null || !player.isAlive() || player.tickCount <= 0 || player.isRemoved())
|
||||
if (to.connection == null)
|
||||
return false;
|
||||
return AttachmentSyncHandler.super.sendToPlayer(holder, to);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
package tschipp.carryon.compat;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import tschipp.carryon.config.BuiltConfig;
|
||||
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
|
||||
|
||||
|
||||
public record ClothConfigCompatNeo(BuiltConfig client, BuiltConfig common) implements IConfigScreenFactory {
|
||||
|
||||
@Override
|
||||
public Screen createScreen(ModContainer modContainer, Screen screen) {
|
||||
return ClothConfigCompat.getConfigScreen(client, common, screen, () -> {ConfigLoaderImpl.saveConfig(client); ConfigLoaderImpl.saveConfig(common);});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -36,10 +36,10 @@ import tschipp.carryon.config.PropertyData;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID)
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
|
||||
public class ConfigLoaderImpl {
|
||||
|
||||
public static final Map<ModConfigSpec, BuiltConfig> CONFIGS = new LinkedHashMap<>();
|
||||
public static final Map<ModConfigSpec, BuiltConfig> CONFIGS = new HashMap<>();
|
||||
|
||||
public static void initialize(ModContainer container) {
|
||||
|
||||
|
|
@ -55,10 +55,25 @@ public class ConfigLoaderImpl {
|
|||
@SubscribeEvent
|
||||
public static void onConfigLoad(ModConfigEvent.Loading loading) {
|
||||
loadConfig((ModConfigSpec) loading.getConfig().getSpec());
|
||||
|
||||
// DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||
// });
|
||||
//
|
||||
// DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||
// });
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onConfigReload(ModConfigEvent.Reloading loading) {
|
||||
loadConfig((ModConfigSpec) loading.getConfig().getSpec());
|
||||
loadConfig((ModConfigSpec) loading.getConfig().getSpec());
|
||||
// DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(Minecraft.getInstance().level.registryAccess());
|
||||
// });
|
||||
//
|
||||
// DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
|
||||
// ConfigLoader.onConfigLoaded(ServerLifecycleHooks.getCurrentServer().registryAccess());
|
||||
// });
|
||||
}
|
||||
|
||||
private static void loadConfig(ModConfigSpec spec) {
|
||||
|
|
@ -86,15 +101,6 @@ public class ConfigLoaderImpl {
|
|||
});
|
||||
}
|
||||
|
||||
public static void saveConfig(BuiltConfig cfg) {
|
||||
for (Map.Entry<ModConfigSpec, BuiltConfig> entry : CONFIGS.entrySet()) {
|
||||
if(entry.getValue() == cfg) {
|
||||
ModConfigSpec spec = entry.getKey();
|
||||
spec.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerConfig(BuiltConfig config) {
|
||||
try {
|
||||
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
||||
|
|
@ -114,13 +120,11 @@ public class ConfigLoaderImpl {
|
|||
builder.pop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void buildProperty(ModConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
|
||||
AnnotationData annotationData = data.getData();
|
||||
AnnotationData annotationData = data.data();
|
||||
builder.comment(annotationData.description());
|
||||
|
||||
|
||||
ModConfigSpec.ConfigValue val = switch (annotationData.type()) {
|
||||
switch (annotationData.type()) {
|
||||
case BOOLEAN -> builder.define(data.getId(), data.getBoolean());
|
||||
case INT -> builder.defineInRange(data.getId(), data.getInt(), annotationData.min(), annotationData.max());
|
||||
case DOUBLE -> builder.defineInRange(data.getId(), data.getDouble(), annotationData.minD(), annotationData.maxD());
|
||||
|
|
@ -133,8 +137,6 @@ public class ConfigLoaderImpl {
|
|||
return new ArrayList<>();
|
||||
}, obj -> obj instanceof String);
|
||||
default -> throw new IllegalAccessException("Unknown property type.");
|
||||
};
|
||||
|
||||
data.setSetter(val::set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,15 @@ package tschipp.carryon.events;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
import net.neoforged.neoforge.client.event.RenderHandEvent;
|
||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||
import tschipp.carryon.CarryOnCommonClient;
|
||||
import tschipp.carryon.Constants;
|
||||
|
|
@ -38,22 +40,32 @@ import tschipp.carryon.client.render.CarryRenderHelper;
|
|||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ClientEvents {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void renderHand(RenderHandEvent event)
|
||||
{
|
||||
Player player = Minecraft.getInstance().player;
|
||||
MultiBufferSource buffer = event.getMultiBufferSource();
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
int light = event.getPackedLight();
|
||||
float partialTicks = event.getPartialTick();
|
||||
SubmitNodeCollector nodes =event.getSubmitNodeCollector();
|
||||
|
||||
if(CarriedObjectRender.draw(player, matrix, light, partialTicks,nodes,true) && CarryRenderHelper.getPerspective() == 0)
|
||||
if(CarriedObjectRender.drawFirstPerson(player, buffer, matrix, light, partialTicks) && CarryRenderHelper.getPerspective() == 0)
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onRenderLevel(RenderLevelStageEvent event)
|
||||
{
|
||||
if(event.getStage() == RenderLevelStageEvent.Stage.AFTER_PARTICLES)
|
||||
CarriedObjectRender.drawThirdPerson(event.getPartialTick().getGameTimeDeltaPartialTick(true), event.getPoseStack().last().pose());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onGuiInit(ScreenEvent.Init.Pre event)
|
||||
{
|
||||
|
|
@ -77,6 +89,7 @@ public class ClientEvents {
|
|||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void onClientTick(ClientTickEvent.Post event)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.TriState;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
|
|
@ -36,10 +34,12 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.common.util.BlockSnapshot;
|
||||
import net.neoforged.neoforge.event.AddServerReloadListenersEvent;
|
||||
import net.neoforged.neoforge.common.util.TriState;
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
||||
import net.neoforged.neoforge.event.OnDatapackSyncEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.TagsUpdatedEvent;
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.MobSpawnEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
|
|
@ -56,8 +56,10 @@ import tschipp.carryon.common.carry.PickupHandler;
|
|||
import tschipp.carryon.common.carry.PlacementHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.networking.clientbound.ClientboundSyncCarryDataPacket;
|
||||
import tschipp.carryon.platform.Services;
|
||||
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID)
|
||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, modid = Constants.MOD_ID)
|
||||
public class CommonEvents
|
||||
{
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
|
|
@ -70,7 +72,7 @@ public class CommonEvents
|
|||
Level level = event.getLevel();
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
if (level.isClientSide())
|
||||
if (level.isClientSide)
|
||||
return;
|
||||
|
||||
boolean success = false;
|
||||
|
|
@ -96,7 +98,7 @@ public class CommonEvents
|
|||
PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> {
|
||||
if (toPlace instanceof Mob mob) {
|
||||
mob.setPos(pPos.x, pPos.y, pPos.z);
|
||||
MobSpawnEvent.PositionCheck checkSpawn = new MobSpawnEvent.PositionCheck(mob, (ServerLevelAccessor) level, EntitySpawnReason.EVENT, null);
|
||||
MobSpawnEvent.PositionCheck checkSpawn = new MobSpawnEvent.PositionCheck(mob, (ServerLevelAccessor) level, MobSpawnType.EVENT, null);
|
||||
NeoForge.EVENT_BUS.post(checkSpawn);
|
||||
return checkSpawn.getResult() != MobSpawnEvent.PositionCheck.Result.FAIL;
|
||||
}
|
||||
|
|
@ -124,7 +126,7 @@ public class CommonEvents
|
|||
Level level = event.getLevel();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (level.isClientSide())
|
||||
if (level.isClientSide)
|
||||
return;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
|
|
@ -150,9 +152,9 @@ public class CommonEvents
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onDatapackRegister(AddServerReloadListenersEvent event)
|
||||
public static void onDatapackRegister(AddReloadListenerEvent event)
|
||||
{
|
||||
event.addListener(Identifier.fromNamespaceAndPath(Constants.MOD_ID, "scripts"), new ScriptReloadListener());
|
||||
event.addListener(new ScriptReloadListener());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -169,7 +171,7 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
public static void onTagsUpdate(TagsUpdatedEvent event)
|
||||
{
|
||||
ConfigLoader.onConfigLoaded(event.getLookupProvider());
|
||||
ConfigLoader.onConfigLoaded(event.getRegistryAccess());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -182,7 +184,7 @@ public class CommonEvents
|
|||
@SubscribeEvent
|
||||
public static void onClone(PlayerEvent.Clone event)
|
||||
{
|
||||
if (!event.getOriginal().level().isClientSide())
|
||||
if (!event.getOriginal().level().isClientSide)
|
||||
PlacementHandler.placeCarriedOnDeath((ServerPlayer) event.getOriginal(), (ServerPlayer) event.getEntity(), event.isWasDeath());
|
||||
}
|
||||
|
||||
|
|
@ -221,6 +223,20 @@ public class CommonEvents
|
|||
CarryOnCommon.onRiderDisconnected(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onStartTracking(PlayerEvent.StartTracking event) {
|
||||
if(event.getEntity() instanceof ServerPlayer sp && event.getTarget() instanceof ServerPlayer target) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), target);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onJoinWorld(EntityJoinLevelEvent event) {
|
||||
if (event.getEntity() instanceof ServerPlayer sp) {
|
||||
Services.PLATFORM.sendPacketToPlayer(Constants.PACKET_ID_SYNC_CARRY_ON_DATA, new ClientboundSyncCarryDataPacket(sp.getId(), CarryOnDataManager.getCarryData(sp)), sp);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerDie(LivingDeathEvent event) {
|
||||
if(event.getEntity() instanceof ServerPlayer sp) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import tschipp.carryon.common.config.ListHandler;
|
|||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID)
|
||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = Constants.MOD_ID)
|
||||
public class ModBusEvents {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
|
|
|
|||
|
|
@ -21,15 +21,17 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||
import tschipp.carryon.Constants;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
|
||||
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = Constants.MOD_ID, value = Dist.CLIENT)
|
||||
public class ModClientEvents
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registerKeybinds(RegisterKeyMappingsEvent event)
|
||||
{
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user