Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afd9e8ac65 | ||
|
|
ac5f9447db | ||
|
|
e01cc75e5d | ||
|
|
e1da67a250 | ||
|
|
1e5adfdc27 | ||
|
|
3241c1b090 | ||
|
|
0d36a04c5b | ||
|
|
7785b39f7f | ||
|
|
ad67da7535 | ||
|
|
ad46b60e23 |
26
build.gradle
26
build.gradle
|
|
@ -19,9 +19,7 @@ apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
||||||
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
||||||
apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle'
|
apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle'
|
||||||
|
|
||||||
//import net.minecraftforge.gradle.common.task.SignJar
|
//import net.minecraftforge.gradle.common.task.SignJar
|
||||||
import groovy.json.JsonSlurper
|
|
||||||
import groovy.json.JsonOutput
|
|
||||||
|
|
||||||
if (project.hasProperty('secretFile')) {
|
if (project.hasProperty('secretFile')) {
|
||||||
loadSecrets(new File((String) findProperty('secretFile')))
|
loadSecrets(new File((String) findProperty('secretFile')))
|
||||||
|
|
@ -117,19 +115,19 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
//implementation fg.deobf("net.darkhax.gamestages:GameStages-1.16.4:6.0.1")
|
implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.18.2:8.1.3")
|
||||||
//implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-1.16.4:9.3.18")
|
implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.18.2:13.2.53")
|
||||||
//implementation fg.deobf("curse.maven:obfuscate-289380:3169370")
|
//implementation fg.deobf("curse.maven:obfuscate-289380:3169370")
|
||||||
|
|
||||||
//fileTree("libs").matching {
|
fileTree("libs").matching {
|
||||||
// include "*.jar"
|
include "*.jar"
|
||||||
//}.each {
|
}.each {
|
||||||
// String filename = it.getName();
|
String filename = it.getName();
|
||||||
// filename = filename.substring(0, filename.length() - 4);
|
filename = filename.substring(0, filename.length() - 4);
|
||||||
// int lastDash = filename.lastIndexOf("-");
|
int lastDash = filename.lastIndexOf("-");
|
||||||
// filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||||
// implementation fg.deobf("blank:${filename}")
|
implementation fg.deobf("blank:${filename}")
|
||||||
//}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
version=1.17.0
|
version=1.17.2
|
||||||
minecraft_version=1.18.2
|
minecraft_version=1.18.2
|
||||||
mappings_version=2022.02.13-1.18.1
|
mappings_version=2022.09.04-1.18.2
|
||||||
forge_version=40.0.3
|
forge_version=40.2.14
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
# chorg.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-17.0.1/
|
# chorg.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-17.0.1/
|
||||||
|
|
@ -1,16 +1,10 @@
|
||||||
package tschipp.carryon;
|
package tschipp.carryon;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.InterModComms;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
@ -21,22 +15,22 @@ import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.network.NetworkDirection;
|
import net.minecraftforge.network.NetworkDirection;
|
||||||
import net.minecraftforge.network.NetworkRegistry;
|
import net.minecraftforge.network.NetworkRegistry;
|
||||||
import net.minecraftforge.network.simple.SimpleChannel;
|
import net.minecraftforge.network.simple.SimpleChannel;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import tschipp.carryon.common.config.Configs;
|
import tschipp.carryon.common.config.Configs;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||||
import tschipp.carryon.proxy.ClientProxy;
|
|
||||||
import tschipp.carryon.proxy.IProxy;
|
import java.io.File;
|
||||||
import tschipp.carryon.proxy.ServerProxy;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Mod(CarryOn.MODID)
|
@Mod(CarryOn.MODID)
|
||||||
@EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class CarryOn
|
public class CarryOn
|
||||||
{
|
{
|
||||||
|
|
||||||
public static IProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
|
||||||
|
|
||||||
public static final String MODID = "carryon";
|
public static final String MODID = "carryon";
|
||||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||||
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
|
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
|
||||||
|
|
@ -75,8 +69,6 @@ public class CarryOn
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
RegistrationHandler.regOverrideList();
|
RegistrationHandler.regOverrideList();
|
||||||
|
|
||||||
proxy.setup(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ public class RenderEntityEvents
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
if (ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
if (ModList.get().isLoaded("firstperson") || ModList.get().isLoaded("firstpersonmod"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Entity entity = getEntity(stack, level);
|
Entity entity = getEntity(stack, level);
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
package tschipp.carryon.client.event;
|
package tschipp.carryon.client.event;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Quaternion;
|
import com.mojang.math.Quaternion;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
@ -71,8 +68,22 @@ import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class RenderEvents
|
public class RenderEvents
|
||||||
{
|
{
|
||||||
|
private static Map<RenderType, BufferBuilder> builders = Map.of(
|
||||||
|
RenderType.glint(), new BufferBuilder(RenderType.glint().bufferSize()),
|
||||||
|
RenderType.glintDirect(), new BufferBuilder(RenderType.glintDirect().bufferSize()),
|
||||||
|
RenderType.glintTranslucent(), new BufferBuilder(RenderType.glintTranslucent().bufferSize()),
|
||||||
|
RenderType.entityGlint(), new BufferBuilder(RenderType.entityGlint().bufferSize()),
|
||||||
|
RenderType.entityGlintDirect(), new BufferBuilder(RenderType.entityGlintDirect().bufferSize())
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prevents the Player from scrolling
|
* Prevents the Player from scrolling
|
||||||
*/
|
*/
|
||||||
|
|
@ -165,7 +176,8 @@ public class RenderEvents
|
||||||
|
|
||||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().player.closeContainer();
|
event.setCanceled(true);
|
||||||
|
//Minecraft.getInstance().player.closeContainer();
|
||||||
Minecraft.getInstance().screen = null;
|
Minecraft.getInstance().screen = null;
|
||||||
Minecraft.getInstance().mouseHandler.grabMouse();
|
Minecraft.getInstance().mouseHandler.grabMouse();
|
||||||
|
|
||||||
|
|
@ -243,7 +255,7 @@ public class RenderEvents
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
||||||
{
|
{
|
||||||
if (ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
if (ModList.get().isLoaded("firstperson") || ModList.get().isLoaded("firstpersonmod"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Block block = ItemCarryonBlock.getBlock(stack);
|
Block block = ItemCarryonBlock.getBlock(stack);
|
||||||
|
|
@ -318,7 +330,6 @@ public class RenderEvents
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
Level level = mc.level;
|
Level level = mc.level;
|
||||||
float partialticks = event.getPartialTick();
|
float partialticks = event.getPartialTick();
|
||||||
BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
|
||||||
PoseStack matrix = event.getPoseStack();
|
PoseStack matrix = event.getPoseStack();
|
||||||
int light = 0;
|
int light = 0;
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
|
|
@ -327,117 +338,121 @@ public class RenderEvents
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
|
BufferSource buffer = MultiBufferSource.immediateWithBuffers(builders, Tesselator.getInstance().getBuilder());
|
||||||
|
|
||||||
|
|
||||||
for (Player player : level.players())
|
for (Player player : level.players())
|
||||||
{
|
{
|
||||||
if (perspective == 0 && player == mc.player)
|
try {
|
||||||
continue;
|
|
||||||
|
|
||||||
light = manager.getPackedLightCoords(player, partialticks);
|
if (perspective == 0 && player == mc.player && !(ModList.get().isLoaded("firstperson") || ModList.get().isLoaded("firstpersonmod")))
|
||||||
ItemStack stack = player.getMainHandItem();
|
continue;
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
light = manager.getPackedLightCoords(player, partialticks);
|
||||||
{
|
ItemStack stack = player.getMainHandItem();
|
||||||
Block block = ItemCarryonBlock.getBlock(stack);
|
|
||||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
|
||||||
CompoundTag tag = ItemCarryonBlock.getTileData(stack);
|
|
||||||
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
|
||||||
|
|
||||||
applyBlockTransformations(player, partialticks, matrix, block);
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) {
|
||||||
|
Block block = ItemCarryonBlock.getBlock(stack);
|
||||||
|
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||||
|
CompoundTag tag = ItemCarryonBlock.getTileData(stack);
|
||||||
|
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
||||||
|
|
||||||
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, level, player) : tileItem.isEmpty() ? mc.getBlockRenderer().getBlockModel(state) : mc.getItemRenderer().getModel(tileItem, level, player, 0);
|
applyBlockTransformations(player, partialticks, matrix, block);
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, level, player) : tileItem.isEmpty() ? mc.getBlockRenderer().getBlockModel(state) : mc.getItemRenderer().getModel(tileItem, level, player, 0);
|
||||||
if (carryOverride != null)
|
|
||||||
{
|
|
||||||
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
|
||||||
|
|
||||||
if (!carryOverride.getRenderNameBlock().isEmpty())
|
|
||||||
{
|
|
||||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
|
||||||
if (b != null)
|
|
||||||
{
|
|
||||||
ItemStack s = new ItemStack(b, 1);
|
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
|
||||||
model = mc.getItemRenderer().getModel(s, level, player, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
|
||||||
RenderSystem.enableCull();
|
|
||||||
|
|
||||||
PoseStack.Pose p = matrix.last();
|
|
||||||
PoseStack copy = new PoseStack();
|
|
||||||
copy.mulPoseMatrix(p.pose());
|
|
||||||
matrix.popPose();
|
|
||||||
drawArms(player, partialticks, matrix, buffer, light);
|
|
||||||
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
CarryRenderHelper.renderItem(state, tag, stack, tileItem, copy, buffer, light, model);
|
|
||||||
buffer.endBatch();
|
|
||||||
|
|
||||||
matrix.popPose();
|
|
||||||
}
|
|
||||||
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
Entity entity = RenderEntityEvents.getEntity(stack, level);
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
applyEntityTransformations(player, partialticks, matrix, entity);
|
|
||||||
|
|
||||||
manager.setRenderShadow(false);
|
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null) {
|
||||||
{
|
|
||||||
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
|
|
||||||
String entityname = carryOverride.getRenderNameEntity();
|
if (!carryOverride.getRenderNameBlock().isEmpty()) {
|
||||||
if (entityname != null)
|
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||||
{
|
if (b != null) {
|
||||||
Entity newEntity = null;
|
ItemStack s = new ItemStack(b, 1);
|
||||||
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
Optional<EntityType<?>> type = EntityType.byString(entityname);
|
model = mc.getItemRenderer().getModel(s, level, player, 0);
|
||||||
if (type.isPresent())
|
|
||||||
newEntity = type.get().create(level);
|
|
||||||
|
|
||||||
if (newEntity != null)
|
|
||||||
{
|
|
||||||
CompoundTag nbttag = carryOverride.getRenderNBT();
|
|
||||||
if (nbttag != null)
|
|
||||||
newEntity.deserializeNBT(nbttag);
|
|
||||||
entity = newEntity;
|
|
||||||
entity.yo = 0.0f;
|
|
||||||
entity.yRotO = 0.0f;
|
|
||||||
entity.setYHeadRot(0.0f);
|
|
||||||
entity.xo = 0.0f;
|
|
||||||
entity.xRotO = 0.0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof LivingEntity le)
|
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||||
le.hurtTime = 0;
|
RenderSystem.enableCull();
|
||||||
|
|
||||||
|
PoseStack.Pose p = matrix.last();
|
||||||
|
PoseStack copy = new PoseStack();
|
||||||
|
copy.mulPoseMatrix(p.pose());
|
||||||
|
matrix.popPose();
|
||||||
|
drawArms(player, partialticks, matrix, buffer, light);
|
||||||
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
CarryRenderHelper.renderItem(state, tag, stack, tileItem, copy, buffer, light, model);
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
|
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
|
} else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) {
|
||||||
|
Entity entity = RenderEntityEvents.getEntity(stack, level);
|
||||||
|
|
||||||
drawArms(player, partialticks, matrix, buffer, light);
|
if (entity != null) {
|
||||||
|
applyEntityTransformations(player, partialticks, matrix, entity);
|
||||||
|
|
||||||
manager.setRenderShadow(true);
|
manager.setRenderShadow(false);
|
||||||
|
|
||||||
matrix.popPose();
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
|
if (carryOverride != null) {
|
||||||
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
|
|
||||||
|
String entityname = carryOverride.getRenderNameEntity();
|
||||||
|
if (entityname != null) {
|
||||||
|
Entity newEntity = null;
|
||||||
|
|
||||||
|
Optional<EntityType<?>> type = EntityType.byString(entityname);
|
||||||
|
if (type.isPresent())
|
||||||
|
newEntity = type.get().create(level);
|
||||||
|
|
||||||
|
if (newEntity != null) {
|
||||||
|
CompoundTag nbttag = carryOverride.getRenderNBT();
|
||||||
|
if (nbttag != null)
|
||||||
|
newEntity.deserializeNBT(nbttag);
|
||||||
|
entity = newEntity;
|
||||||
|
entity.yo = 0.0f;
|
||||||
|
entity.yRotO = 0.0f;
|
||||||
|
entity.setYHeadRot(0.0f);
|
||||||
|
entity.xo = 0.0f;
|
||||||
|
entity.xRotO = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
drawArms(player, partialticks, matrix, buffer, light);
|
||||||
|
|
||||||
|
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.enableDepthTest();
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
package tschipp.carryon.common.config;
|
package tschipp.carryon.common.config;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
|
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||||
|
|
@ -18,6 +14,9 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD)
|
@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD)
|
||||||
public class Configs
|
public class Configs
|
||||||
{
|
{
|
||||||
|
|
@ -28,8 +27,7 @@ public class Configs
|
||||||
public static final ForgeConfigSpec SERVER_CONFIG;
|
public static final ForgeConfigSpec SERVER_CONFIG;
|
||||||
public static final ForgeConfigSpec CLIENT_CONFIG;
|
public static final ForgeConfigSpec CLIENT_CONFIG;
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
|
||||||
|
|
||||||
Settings.init(SERVER_BUILDER, CLIENT_BUILDER);
|
Settings.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||||
Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER);
|
Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||||
|
|
@ -44,8 +42,7 @@ public class Configs
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onLoad(final ModConfigEvent.Loading event)
|
public static void onLoad(final ModConfigEvent.Loading event)
|
||||||
{
|
{
|
||||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
if (event.getConfig().getModId().equals(CarryOn.MODID)) {
|
||||||
{
|
|
||||||
ListHandler.initConfigLists();
|
ListHandler.initConfigLists();
|
||||||
|
|
||||||
CommentedConfig cfg = event.getConfig().getConfigData();
|
CommentedConfig cfg = event.getConfig().getConfigData();
|
||||||
|
|
@ -58,8 +55,7 @@ public class Configs
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onConfigChanged(ModConfigEvent.Reloading event)
|
public static void onConfigChanged(ModConfigEvent.Reloading event)
|
||||||
{
|
{
|
||||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
if (event.getConfig().getModId().equals(CarryOn.MODID)) {
|
||||||
{
|
|
||||||
ListHandler.initConfigLists();
|
ListHandler.initConfigLists();
|
||||||
|
|
||||||
CommentedConfig cfg = event.getConfig().getConfigData();
|
CommentedConfig cfg = event.getConfig().getConfigData();
|
||||||
|
|
@ -165,7 +161,7 @@ public class Configs
|
||||||
|
|
||||||
stackableEntities = s.comment("Allows entities to be stacked using Carry On").define("stackableEntities", true);
|
stackableEntities = s.comment("Allows entities to be stacked using Carry On").define("stackableEntities", true);
|
||||||
|
|
||||||
entitySizeMattersStacking = s.comment("Whether entities' size matters when stacking or not").define("stackableEntities", true);
|
entitySizeMattersStacking = s.comment("Whether entities' size matters when stacking or not").define("entitySizeMattersStacking", true);
|
||||||
|
|
||||||
s.pop();
|
s.pop();
|
||||||
c.pop();
|
c.pop();
|
||||||
|
|
@ -206,9 +202,11 @@ public class Configs
|
||||||
{
|
{
|
||||||
s.comment("Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
s.comment("Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
||||||
|
|
||||||
forbiddenTiles = s.comment("Blocks that cannot be picked up").defineList("blacklist.forbiddenTiles", Arrays.asList("#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony", "minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed", "minecraft:oak_door", "minecraft:iron_door", "minecraft:spruce_door", "minecraft:birch_door", "minecraft:jungle_door", "minecraft:acacia_door", "minecraft:dark_oak_door", "minecraft:waterlily", "minecraft:cake", "minecraft:nether_portal", "minecraft:tall_seagrass", "animania:block_trough", "animania:block_invisiblock", "colossalchests:*", "ic2:*", "bigreactors:*", "forestry:*", "tconstruct:*", "rustic:*", "botania:*", "astralsorcery:*", "quark:colored_bed_*", "immersiveengineering:*", "embers:block_furnace", "embers:ember_bore", "embers:ember_activator", "embers:mixer", "embers:heat_coil", "embers:large_tank", "embers:crystal_cell", "embers:alchemy_pedestal", "embers:boiler", "embers:combustor", "embers:catalzyer", "embers:field_chart", "embers:inferno_forge", "storagedrawers:framingtable", "skyresources:*", "lootbags:*", "exsartagine:*", "aquamunda:tank", "opencomputers:*", "malisisdoors:*", "industrialforegoing:*", "minecolonies:*", "thaumcraft:pillar*", "thaumcraft:infernal_furnace", "thaumcraft:placeholder*", "thaumcraft:infusion_matrix", "thaumcraft:golem_builder", "thaumcraft:thaumatorium*", "magneticraft:oil_heater", "magneticraft:solar_panel", "magneticraft:steam_engine", "magneticraft:shelving_unit", "magneticraft:grinder", "magneticraft:sieve", "magneticraft:solar_tower", "magneticraft:solar_mirror", "magneticraft:container", "magneticraft:pumpjack", "magneticraft:solar_panel", "magneticraft:refinery", "magneticraft:oil_heater", "magneticraft:hydraulic_press", "magneticraft:multiblock_gap", "refinedstorage:*", "mcmultipart:*", "enderstorage:*", "betterstorage:*", "practicallogistics2:*", "wearablebackpacks:*", "rftools:screen", "rftools:creative_screen", "create:*", "magic_doorknob:*", "iceandfire:*", "ftbquests:*", "waystones:*"), obj -> obj instanceof String);
|
forbiddenTiles = s.comment("Blocks that cannot be picked up").defineList("blacklist.forbiddenTiles", Arrays.asList("#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony", "minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed", "minecraft:oak_door", "minecraft:iron_door", "minecraft:spruce_door", "minecraft:birch_door", "minecraft:jungle_door", "minecraft:acacia_door", "minecraft:dark_oak_door", "minecraft:waterlily", "minecraft:cake", "minecraft:nether_portal", "minecraft:tall_seagrass", "animania:block_trough", "animania:block_invisiblock", "colossalchests:*", "ic2:*", "bigreactors:*", "forestry:*", "tconstruct:*", "rustic:*", "botania:*", "astralsorcery:*", "quark:colored_bed_*", "immersiveengineering:*", "embers:block_furnace", "embers:ember_bore", "embers:ember_activator", "embers:mixer", "embers:heat_coil", "embers:large_tank", "embers:crystal_cell", "embers:alchemy_pedestal", "embers:boiler", "embers:combustor", "embers:catalzyer", "embers:field_chart", "embers:inferno_forge", "storagedrawers:framingtable", "skyresources:*", "lootbags:*", "exsartagine:*", "aquamunda:tank", "opencomputers:*", "malisisdoors:*", "industrialforegoing:*", "minecolonies:*", "thaumcraft:pillar*", "thaumcraft:infernal_furnace", "thaumcraft:placeholder*", "thaumcraft:infusion_matrix", "thaumcraft:golem_builder", "thaumcraft:thaumatorium*", "magneticraft:oil_heater", "magneticraft:solar_panel", "magneticraft:steam_engine", "magneticraft:shelving_unit", "magneticraft:grinder", "magneticraft:sieve", "magneticraft:solar_tower", "magneticraft:solar_mirror", "magneticraft:container", "magneticraft:pumpjack", "magneticraft:solar_panel", "magneticraft:refinery", "magneticraft:oil_heater", "magneticraft:hydraulic_press", "magneticraft:multiblock_gap", "refinedstorage:*", "mcmultipart:*", "enderstorage:*", "betterstorage:*", "practicallogistics2:*", "wearablebackpacks:*", "rftools:screen", "rftools:creative_screen", "create:*", "magic_doorknob:*", "iceandfire:*", "ftbquests:*", "waystones:*", "framedblocks:*", "securitycraft:*", "forgemultipartcbe:*", "integrateddynamics:cable",
|
||||||
|
"mekanismgenerators:wind_generator", "vm:vending_machine"), obj -> obj instanceof String);
|
||||||
|
|
||||||
forbiddenEntities = s.comment("Entities that cannot be picked up").defineList("blacklist.forbiddenEntities", Arrays.asList("minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", "minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand", "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart", "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*"), obj -> obj instanceof String ? true : false);
|
forbiddenEntities = s.comment("Entities that cannot be picked up").defineList("blacklist.forbiddenEntities", Arrays.asList("minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", "minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand", "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart", "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*",
|
||||||
|
"securitycraft:*", "taterzens:npc", "easy_npc:*", "minecolonies:*"), obj -> obj instanceof String ? true : false);
|
||||||
|
|
||||||
forbiddenStacking = s.comment("Entities that cannot have other entities stacked on top of them").defineList("blacklist.forbiddenStacking", Arrays.asList("minecraft:horse"), obj -> obj instanceof String ? true : false);
|
forbiddenStacking = s.comment("Entities that cannot have other entities stacked on top of them").defineList("blacklist.forbiddenStacking", Arrays.asList("minecraft:horse"), obj -> obj instanceof String ? true : false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,62 @@
|
||||||
package tschipp.carryon.common.event;
|
package tschipp.carryon.common.event;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.InterModComms;
|
import net.minecraftforge.fml.InterModComms;
|
||||||
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@EventBusSubscriber(modid = CarryOn.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class IMCEvents
|
public class IMCEvents
|
||||||
{
|
{
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOW)
|
@SubscribeEvent(priority = EventPriority.LOW)
|
||||||
public void serverLoad(FMLDedicatedServerSetupEvent event)
|
public static void serverLoad(InterModProcessEvent event)
|
||||||
{
|
{
|
||||||
Stream<IMCMessage> messages = InterModComms.getMessages(CarryOn.MODID);
|
Stream<IMCMessage> messages = InterModComms.getMessages(CarryOn.MODID);
|
||||||
|
|
||||||
messages.forEach(msg -> {
|
messages.forEach(msg -> {
|
||||||
|
|
||||||
String method = msg.method();
|
ListHandler.IMCMessages.add(() -> {
|
||||||
Object obj = msg.messageSupplier().get();
|
String method = msg.method();
|
||||||
|
Object obj = msg.messageSupplier().get();
|
||||||
|
|
||||||
if (!(obj instanceof String str))
|
if (!(obj instanceof String str))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (method)
|
switch (method) {
|
||||||
{
|
case "blacklistBlock":
|
||||||
case "blacklistBlock":
|
ListHandler.FORBIDDEN_TILES.add(str);
|
||||||
ListHandler.FORBIDDEN_TILES.add(str);
|
break;
|
||||||
break;
|
case "blacklistEntity":
|
||||||
case "blacklistEntity":
|
ListHandler.FORBIDDEN_ENTITIES.add(str);
|
||||||
ListHandler.FORBIDDEN_ENTITIES.add(str);
|
break;
|
||||||
break;
|
case "whitelistBlock":
|
||||||
case "whitelistBlock":
|
ListHandler.ALLOWED_TILES.add(str);
|
||||||
ListHandler.ALLOWED_TILES.add(str);
|
break;
|
||||||
break;
|
case "whitelistEntity":
|
||||||
case "whitelistEntity":
|
ListHandler.ALLOWED_ENTITIES.add(str);
|
||||||
ListHandler.ALLOWED_ENTITIES.add(str);
|
break;
|
||||||
break;
|
case "blacklistStacking":
|
||||||
case "blacklistStacking":
|
ListHandler.FORBIDDEN_STACKING.add(str);
|
||||||
ListHandler.FORBIDDEN_STACKING.add(str);
|
break;
|
||||||
break;
|
case "whitelistStacking":
|
||||||
case "whitelistStacking":
|
ListHandler.ALLOWED_STACKING.add(str);
|
||||||
ListHandler.ALLOWED_STACKING.add(str);
|
break;
|
||||||
break;
|
case "addModelOverride":
|
||||||
case "addModelOverride":
|
ModelOverridesHandler.parseOverride(str, 0);
|
||||||
ModelOverridesHandler.parseOverride(str, 0);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package tschipp.carryon.common.event;
|
package tschipp.carryon.common.event;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
|
@ -62,6 +60,8 @@ import tschipp.carryon.common.scripting.ScriptReader;
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = CarryOn.MODID)
|
@EventBusSubscriber(modid = CarryOn.MODID)
|
||||||
public class ItemEvents
|
public class ItemEvents
|
||||||
{
|
{
|
||||||
|
|
@ -196,6 +196,7 @@ public class ItemEvents
|
||||||
public void reloadTags(TagsUpdatedEvent event)
|
public void reloadTags(TagsUpdatedEvent event)
|
||||||
{
|
{
|
||||||
ListHandler.initConfigLists();
|
ListHandler.initConfigLists();
|
||||||
|
CustomPickupOverrideHandler.initPickupOverrides();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,23 @@
|
||||||
package tschipp.carryon.common.handler;
|
package tschipp.carryon.common.handler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraftforge.fml.InterModComms;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.config.Configs.Blacklist;
|
import tschipp.carryon.common.config.Configs.Blacklist;
|
||||||
import tschipp.carryon.common.config.Configs.WhiteList;
|
import tschipp.carryon.common.config.Configs.WhiteList;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ListHandler
|
public class ListHandler
|
||||||
{
|
{
|
||||||
public static List<String> FORBIDDEN_TILES = new ArrayList<>();
|
public static List<String> FORBIDDEN_TILES = new ArrayList<>();
|
||||||
|
|
@ -30,6 +33,7 @@ public class ListHandler
|
||||||
public static List<TagKey<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
public static List<TagKey<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
||||||
public static List<TagKey<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
public static List<TagKey<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
||||||
public static List<TagKey<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
public static List<TagKey<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
||||||
|
public static List<Runnable> IMCMessages = new ArrayList<>();
|
||||||
|
|
||||||
public static boolean isForbidden(Block block)
|
public static boolean isForbidden(Block block)
|
||||||
{
|
{
|
||||||
|
|
@ -51,7 +55,7 @@ public class ListHandler
|
||||||
|
|
||||||
for (TagKey<Block> tag : FORBIDDEN_TILES_TAGS)
|
for (TagKey<Block> tag : FORBIDDEN_TILES_TAGS)
|
||||||
{
|
{
|
||||||
if (block.defaultBlockState().m_204336_(tag))
|
if (block.defaultBlockState().is(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +70,7 @@ public class ListHandler
|
||||||
|
|
||||||
for (TagKey<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
for (TagKey<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
||||||
{
|
{
|
||||||
if (entity.getType().m_204039_(tag))
|
if (entity.getType().is(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +84,7 @@ public class ListHandler
|
||||||
|
|
||||||
for (TagKey<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
for (TagKey<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
||||||
{
|
{
|
||||||
if (entity.getType().m_204039_(tag))
|
if (entity.getType().is(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +98,7 @@ public class ListHandler
|
||||||
|
|
||||||
for (TagKey<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
for (TagKey<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
||||||
{
|
{
|
||||||
if (entity.getType().m_204039_(tag))
|
if (entity.getType().is(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +112,7 @@ public class ListHandler
|
||||||
|
|
||||||
for (TagKey<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
for (TagKey<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
||||||
{
|
{
|
||||||
if (entity.getType().m_204039_(tag))
|
if (entity.getType().is(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +139,7 @@ public class ListHandler
|
||||||
|
|
||||||
for (TagKey<Block> tag : ALLOWED_TILES_TAGS)
|
for (TagKey<Block> tag : ALLOWED_TILES_TAGS)
|
||||||
{
|
{
|
||||||
if (block.defaultBlockState().m_204336_(tag))
|
if (block.defaultBlockState().is(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +148,11 @@ public class ListHandler
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void processIMC() {
|
||||||
|
for(Runnable r : IMCMessages)
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void initConfigLists()
|
public static void initConfigLists()
|
||||||
{
|
{
|
||||||
|
|
@ -160,9 +169,10 @@ public class ListHandler
|
||||||
ALLOWED_TILES.clear();
|
ALLOWED_TILES.clear();
|
||||||
ALLOWED_TILES_TAGS.clear();
|
ALLOWED_TILES_TAGS.clear();
|
||||||
|
|
||||||
|
processIMC();
|
||||||
|
|
||||||
List<String> forbidden = new ArrayList<>(Blacklist.forbiddenTiles.get());
|
List<String> forbidden = new ArrayList<>(Blacklist.forbiddenTiles.get());
|
||||||
forbidden.add("#carryon:block_blacklist");
|
forbidden.add("#carryon:block_blacklist");
|
||||||
FORBIDDEN_TILES = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < forbidden.size(); i++)
|
for (int i = 0; i < forbidden.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -172,7 +182,6 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> forbiddenEntity = new ArrayList<>(Blacklist.forbiddenEntities.get());
|
List<String> forbiddenEntity = new ArrayList<>(Blacklist.forbiddenEntities.get());
|
||||||
forbiddenEntity.add("#carryon:entity_blacklist");
|
forbiddenEntity.add("#carryon:entity_blacklist");
|
||||||
FORBIDDEN_ENTITIES = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < forbiddenEntity.size(); i++)
|
for (int i = 0; i < forbiddenEntity.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -197,7 +206,6 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> allowedEntities = new ArrayList<>(WhiteList.allowedEntities.get());
|
List<String> allowedEntities = new ArrayList<>(WhiteList.allowedEntities.get());
|
||||||
allowedEntities.add("#carryon:entity_whitelist");
|
allowedEntities.add("#carryon:entity_whitelist");
|
||||||
ALLOWED_ENTITIES = new ArrayList<>();
|
|
||||||
for (int i = 0; i < allowedEntities.size(); i++)
|
for (int i = 0; i < allowedEntities.size(); i++)
|
||||||
{
|
{
|
||||||
if (!allowedEntities.get(i).startsWith("#"))
|
if (!allowedEntities.get(i).startsWith("#"))
|
||||||
|
|
@ -221,7 +229,6 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> allowedBlocks = new ArrayList<>(WhiteList.allowedBlocks.get());
|
List<String> allowedBlocks = new ArrayList<>(WhiteList.allowedBlocks.get());
|
||||||
allowedBlocks.add("#carryon:block_whitelist");
|
allowedBlocks.add("#carryon:block_whitelist");
|
||||||
ALLOWED_TILES = new ArrayList<>();
|
|
||||||
for (int i = 0; i < allowedBlocks.size(); i++)
|
for (int i = 0; i < allowedBlocks.size(); i++)
|
||||||
{
|
{
|
||||||
if (!allowedBlocks.get(i).startsWith("#"))
|
if (!allowedBlocks.get(i).startsWith("#"))
|
||||||
|
|
@ -230,7 +237,6 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> forbiddenStacking = new ArrayList<>(Blacklist.forbiddenStacking.get());
|
List<String> forbiddenStacking = new ArrayList<>(Blacklist.forbiddenStacking.get());
|
||||||
forbiddenStacking.add("#carryon:stacking_blacklist");
|
forbiddenStacking.add("#carryon:stacking_blacklist");
|
||||||
FORBIDDEN_STACKING = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < forbiddenStacking.size(); i++)
|
for (int i = 0; i < forbiddenStacking.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -255,7 +261,6 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> allowedStacking = new ArrayList<>(WhiteList.allowedStacking.get());
|
List<String> allowedStacking = new ArrayList<>(WhiteList.allowedStacking.get());
|
||||||
allowedStacking.add("#carryon:stacking_whitelist");
|
allowedStacking.add("#carryon:stacking_whitelist");
|
||||||
ALLOWED_STACKING = new ArrayList<>();
|
|
||||||
for (int i = 0; i < allowedStacking.size(); i++)
|
for (int i = 0; i < allowedStacking.size(); i++)
|
||||||
{
|
{
|
||||||
if (!allowedStacking.get(i).startsWith("#"))
|
if (!allowedStacking.get(i).startsWith("#"))
|
||||||
|
|
@ -277,8 +282,8 @@ public class ListHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ResourceLocation, TagKey<Block>> blocktags = Registry.BLOCK.m_203613_().collect(Collectors.toMap(t -> t.f_203868_(), t -> t));
|
Map<ResourceLocation, TagKey<Block>> blocktags = Registry.BLOCK.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||||
Map<ResourceLocation, TagKey<EntityType<?>>> entitytags = Registry.ENTITY_TYPE.m_203613_().collect(Collectors.toMap(t -> t.f_203868_(), t -> t));
|
Map<ResourceLocation, TagKey<EntityType<?>>> entitytags = Registry.ENTITY_TYPE.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
package tschipp.carryon.common.handler;
|
package tschipp.carryon.common.handler;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
@ -18,14 +14,18 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.Cancelable;
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
import tschipp.carryon.common.helper.CarryonGamestageHelper;
|
import tschipp.carryon.common.helper.CarryonGamestageHelper;
|
||||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PickupHandler
|
public class PickupHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -92,6 +92,9 @@ public class PickupHandler
|
||||||
if (toPickUp instanceof Player)
|
if (toPickUp instanceof Player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if(toPickUp.isRemoved())
|
||||||
|
return false;
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||||
if (override != null)
|
if (override != null)
|
||||||
{
|
{
|
||||||
|
|
@ -164,11 +167,16 @@ public class PickupHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PickUpEntityEvent extends AttackEntityEvent
|
@Cancelable
|
||||||
|
public static class PickUpEntityEvent extends Event
|
||||||
{
|
{
|
||||||
|
public final Player player;
|
||||||
|
public final Entity target;
|
||||||
|
|
||||||
public PickUpEntityEvent(Player player, Entity target)
|
public PickUpEntityEvent(Player player, Entity target)
|
||||||
{
|
{
|
||||||
super(player, target);
|
this.player = player;
|
||||||
|
this.target = target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ public class RegistrationHandler
|
||||||
MinecraftForge.EVENT_BUS.register(new ItemEvents());
|
MinecraftForge.EVENT_BUS.register(new ItemEvents());
|
||||||
MinecraftForge.EVENT_BUS.register(new ItemEntityEvents());
|
MinecraftForge.EVENT_BUS.register(new ItemEntityEvents());
|
||||||
MinecraftForge.EVENT_BUS.register(new PositionCommonEvents());
|
MinecraftForge.EVENT_BUS.register(new PositionCommonEvents());
|
||||||
MinecraftForge.EVENT_BUS.register(new IMCEvents());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void regClientEvents()
|
public static void regClientEvents()
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package tschipp.carryon.common.helper;
|
package tschipp.carryon.common.helper;
|
||||||
|
|
||||||
//import net.darkhax.gamestages.GameStageHelper;
|
//import net.darkhax.gamestages.GameStageHelper;
|
||||||
|
import net.darkhax.gamestages.GameStageHelper;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
public class CarryonGamestageHelper
|
public class CarryonGamestageHelper
|
||||||
{
|
{
|
||||||
public static boolean hasGamestage(String stage, Player player)
|
public static boolean hasGamestage(String stage, Player player)
|
||||||
{
|
{
|
||||||
// return GameStageHelper.hasStage(player, stage);
|
return GameStageHelper.hasStage(player, stage);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package tschipp.carryon.common.helper;
|
package tschipp.carryon.common.helper;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
import org.lwjgl.glfw.GLFWKeyCallback;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.Cancelable;
|
import net.minecraftforge.eventbus.api.Cancelable;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import org.lwjgl.glfw.GLFWKeyCallback;
|
||||||
|
|
||||||
public class KeyboardCallbackWrapper
|
public class KeyboardCallbackWrapper
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package tschipp.carryon.common.helper;
|
package tschipp.carryon.common.helper;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
import org.lwjgl.glfw.GLFWScrollCallback;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.Cancelable;
|
import net.minecraftforge.eventbus.api.Cancelable;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import org.lwjgl.glfw.GLFWScrollCallback;
|
||||||
|
|
||||||
//Thanks to gigaherz for the help!
|
//Thanks to gigaherz for the help!
|
||||||
public class ScrollCallbackWrapper
|
public class ScrollCallbackWrapper
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
package tschipp.carryon.common.item;
|
package tschipp.carryon.common.item;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
import com.google.common.base.CharMatcher;
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
|
@ -42,11 +37,14 @@ import tschipp.carryon.common.event.ItemEvents;
|
||||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class ItemCarryonBlock extends Item
|
public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String TILE_DATA_KEY = "tileData";
|
public static final String TILE_DATA_KEY = "tileData";
|
||||||
public static final String[] FACING_KEYS = { "rotation", "rot", "facing", "face", "direction", "dir", "front", "forward" };
|
public static final String[] FACING_KEYS = {"rotation", "rot", "facing", "face", "direction", "dir", "front", "forward"};
|
||||||
|
|
||||||
public ItemCarryonBlock()
|
public ItemCarryonBlock()
|
||||||
{
|
{
|
||||||
|
|
@ -57,18 +55,15 @@ public class ItemCarryonBlock extends Item
|
||||||
@Override
|
@Override
|
||||||
public Component getName(ItemStack stack)
|
public Component getName(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack)) {
|
||||||
{
|
|
||||||
BlockState state = getBlockState(stack);
|
BlockState state = getBlockState(stack);
|
||||||
CompoundTag nbt = getTileData(stack);
|
CompoundTag nbt = getTileData(stack);
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt)) {
|
||||||
{
|
|
||||||
Object override = ModelOverridesHandler.getOverrideObject(state, nbt);
|
Object override = ModelOverridesHandler.getOverrideObject(state, nbt);
|
||||||
if (override instanceof ItemStack)
|
if (override instanceof ItemStack)
|
||||||
return ((ItemStack) override).getHoverName();
|
return ((ItemStack) override).getHoverName();
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
BlockState ostate = (BlockState) override;
|
BlockState ostate = (BlockState) override;
|
||||||
return ostate.getBlock().getName();
|
return ostate.getBlock().getName();
|
||||||
}
|
}
|
||||||
|
|
@ -92,26 +87,21 @@ public class ItemCarryonBlock extends Item
|
||||||
if (ModList.get().isLoaded("betterplacement") && CarryOnKeybinds.isKeyPressed(player))
|
if (ModList.get().isLoaded("betterplacement") && CarryOnKeybinds.isKeyPressed(player))
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
|
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack)) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
Vec3 vec = player.getLookAngle();
|
Vec3 vec = player.getLookAngle();
|
||||||
Direction facing2 = Direction.getNearest((float) vec.x, 0f, (float) vec.z);
|
Direction facing2 = Direction.getNearest((float) vec.x, 0f, (float) vec.z);
|
||||||
BlockPos pos2 = pos;
|
BlockPos pos2 = pos;
|
||||||
Block containedblock = getBlock(stack);
|
Block containedblock = getBlock(stack);
|
||||||
BlockState containedstate = getBlockState(stack);
|
BlockState containedstate = getBlockState(stack);
|
||||||
if (!level.getBlockState(pos2).canBeReplaced(new BlockPlaceContext(context)))
|
if (!level.getBlockState(pos2).canBeReplaced(new BlockPlaceContext(context))) {
|
||||||
{
|
|
||||||
pos2 = pos.relative(facing);
|
pos2 = pos.relative(facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level.getBlockState(pos2).canBeReplaced(new BlockPlaceContext(context)) && containedblock != null)
|
if (level.getBlockState(pos2).canBeReplaced(new BlockPlaceContext(context)) && containedblock != null) {
|
||||||
{
|
|
||||||
boolean canPlace = containedstate.canSurvive(level, pos2);
|
boolean canPlace = containedstate.canSurvive(level, pos2);
|
||||||
|
|
||||||
if (canPlace && player.mayUseItemAt(pos, facing, stack) && level.mayInteract(player, pos2))
|
if (canPlace && player.mayUseItemAt(pos, facing, stack) && level.mayInteract(player, pos2)) {
|
||||||
{
|
|
||||||
|
|
||||||
BlockState placementState = containedblock.getStateForPlacement(new BlockPlaceContext(context));
|
BlockState placementState = containedblock.getStateForPlacement(new BlockPlaceContext(context));
|
||||||
|
|
||||||
|
|
@ -142,37 +132,32 @@ public class ItemCarryonBlock extends Item
|
||||||
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, level.getBlockState(pos), player);
|
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, level.getBlockState(pos), player);
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
MinecraftForge.EVENT_BUS.post(event);
|
||||||
|
|
||||||
if (!event.isCanceled())
|
if (!event.isCanceled()) {
|
||||||
{
|
|
||||||
level.setBlockAndUpdate(pos2, actualState);
|
level.setBlockAndUpdate(pos2, actualState);
|
||||||
|
|
||||||
// If the blockstate doesn't handle rotation,
|
// If the blockstate doesn't handle rotation,
|
||||||
// try to
|
// try to
|
||||||
// change rotation via NBT
|
// change rotation via NBT
|
||||||
if (!getTileData(stack).isEmpty())
|
if (!getTileData(stack).isEmpty()) {
|
||||||
{
|
|
||||||
CompoundTag tag = getTileData(stack);
|
CompoundTag tag = getTileData(stack);
|
||||||
Set<String> keys = tag.getAllKeys();
|
Set<String> keys = tag.getAllKeys();
|
||||||
keytester: for (String key : keys)
|
keytester:
|
||||||
{
|
for (String key : keys) {
|
||||||
for (String facingKey : FACING_KEYS)
|
for (String facingKey : FACING_KEYS) {
|
||||||
{
|
if (key.toLowerCase().equals(facingKey)) {
|
||||||
if (key.toLowerCase().equals(facingKey))
|
|
||||||
{
|
|
||||||
byte type = tag.getTagType(key);
|
byte type = tag.getTagType(key);
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
case 8:
|
||||||
case 8:
|
tag.putString(key, CharMatcher.javaUpperCase().matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
||||||
tag.putString(key, CharMatcher.javaUpperCase().matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 3:
|
tag.putInt(key, facing2.getOpposite().get3DDataValue());
|
||||||
tag.putInt(key, facing2.getOpposite().get3DDataValue());
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 1:
|
tag.putByte(key, (byte) facing2.getOpposite().get3DDataValue());
|
||||||
tag.putByte(key, (byte) facing2.getOpposite().get3DDataValue());
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break keytester;
|
break keytester;
|
||||||
|
|
@ -182,11 +167,12 @@ public class ItemCarryonBlock extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockEntity tile = level.getBlockEntity(pos2);
|
BlockEntity tile = level.getBlockEntity(pos2);
|
||||||
if (tile != null)
|
if (tile != null) {
|
||||||
{
|
|
||||||
CompoundTag data = getTileData(stack);
|
CompoundTag data = getTileData(stack);
|
||||||
updateTileLocation(data, pos2);
|
updateTileLocation(data, pos2);
|
||||||
tile.load(data);
|
try {
|
||||||
|
tile.load(data);
|
||||||
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
clearTileData(stack);
|
clearTileData(stack);
|
||||||
player.playSound(actualState.getSoundType(level, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
player.playSound(actualState.getSoundType(level, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
||||||
|
|
@ -198,13 +184,10 @@ public class ItemCarryonBlock extends Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
if (level != null && level.isClientSide)
|
if (level != null && level.isClientSide) {
|
||||||
{
|
|
||||||
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(stack));
|
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(stack));
|
||||||
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(stack));
|
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(stack));
|
||||||
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
||||||
|
|
@ -232,26 +215,21 @@ public class ItemCarryonBlock extends Item
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int itemSlot, boolean isSelected)
|
public void inventoryTick(ItemStack stack, Level level, Entity entity, int itemSlot, boolean isSelected)
|
||||||
{
|
{
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack)) {
|
||||||
{
|
if (entity instanceof LivingEntity) {
|
||||||
if (entity instanceof LivingEntity)
|
|
||||||
{
|
|
||||||
if (entity instanceof Player && Settings.slownessInCreative.get() ? false : ((Player) entity).isCreative())
|
if (entity instanceof Player && Settings.slownessInCreative.get() ? false : ((Player) entity).isCreative())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack), false, false));
|
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack), false, false));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasTileData(ItemStack stack)
|
public static boolean hasTileData(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag()) {
|
||||||
{
|
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.contains(TILE_DATA_KEY) && tag.contains("block") && tag.contains("stateid");
|
return tag.contains(TILE_DATA_KEY) && tag.contains("block") && tag.contains("stateid");
|
||||||
}
|
}
|
||||||
|
|
@ -293,8 +271,7 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
public static void clearTileData(ItemStack stack)
|
public static void clearTileData(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag()) {
|
||||||
{
|
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
tag.remove(TILE_DATA_KEY);
|
tag.remove(TILE_DATA_KEY);
|
||||||
tag.remove("block");
|
tag.remove("block");
|
||||||
|
|
@ -304,8 +281,7 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
public static CompoundTag getTileData(ItemStack stack)
|
public static CompoundTag getTileData(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag()) {
|
||||||
{
|
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.getCompound(TILE_DATA_KEY);
|
return tag.getCompound(TILE_DATA_KEY);
|
||||||
}
|
}
|
||||||
|
|
@ -314,8 +290,7 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
public static Block getBlock(ItemStack stack)
|
public static Block getBlock(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag()) {
|
||||||
{
|
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
int id = tag.getInt("stateid");
|
int id = tag.getInt("stateid");
|
||||||
return Block.stateById(id).getBlock();
|
return Block.stateById(id).getBlock();
|
||||||
|
|
@ -341,8 +316,7 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
public static BlockState getBlockState(ItemStack stack)
|
public static BlockState getBlockState(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag()) {
|
||||||
{
|
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
int id = tag.getInt("stateid");
|
int id = tag.getInt("stateid");
|
||||||
return Block.stateById(id);
|
return Block.stateById(id);
|
||||||
|
|
@ -353,8 +327,7 @@ public class ItemCarryonBlock extends Item
|
||||||
public static boolean isLocked(BlockPos pos, Level level)
|
public static boolean isLocked(BlockPos pos, Level level)
|
||||||
{
|
{
|
||||||
BlockEntity te = level.getBlockEntity(pos);
|
BlockEntity te = level.getBlockEntity(pos);
|
||||||
if (te != null)
|
if (te != null) {
|
||||||
{
|
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
te.saveWithId();
|
te.saveWithId();
|
||||||
return tag.contains("Lock") ? !tag.getString("Lock").equals("") : false;
|
return tag.contains("Lock") ? !tag.getString("Lock").equals("") : false;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package tschipp.carryon.network.client;
|
package tschipp.carryon.network.client;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
|
import tschipp.carryon.proxy.ClientProxy;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class CarrySlotPacket
|
public class CarrySlotPacket
|
||||||
{
|
{
|
||||||
|
|
@ -49,7 +49,7 @@ public class CarrySlotPacket
|
||||||
{
|
{
|
||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
|
|
||||||
Level level = CarryOn.proxy.getLevel();
|
Level level = ClientProxy.getLevel();
|
||||||
|
|
||||||
if (level != null)
|
if (level != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,23 @@ package tschipp.carryon.proxy;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper;
|
import tschipp.carryon.common.helper.KeyboardCallbackWrapper;
|
||||||
import tschipp.carryon.common.helper.ScrollCallbackWrapper;
|
import tschipp.carryon.common.helper.ScrollCallbackWrapper;
|
||||||
|
|
||||||
public class ClientProxy implements IProxy
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD, value = Dist.CLIENT)
|
||||||
public void setup(FMLCommonSetupEvent event)
|
public class ClientProxy
|
||||||
|
{
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void setup(FMLClientSetupEvent event)
|
||||||
{
|
{
|
||||||
RegistrationHandler.regClientEvents();
|
RegistrationHandler.regClientEvents();
|
||||||
|
|
||||||
|
|
@ -23,15 +29,12 @@ public class ClientProxy implements IProxy
|
||||||
new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
|
new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static Player getPlayer()
|
||||||
public Player getPlayer()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return Minecraft.getInstance().player;
|
return Minecraft.getInstance().player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static Level getLevel()
|
||||||
public Level getLevel()
|
|
||||||
{
|
{
|
||||||
return Minecraft.getInstance().level;
|
return Minecraft.getInstance().level;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package tschipp.carryon.proxy;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
|
|
||||||
public interface IProxy
|
|
||||||
{
|
|
||||||
|
|
||||||
public void setup(final FMLCommonSetupEvent event);
|
|
||||||
|
|
||||||
public Player getPlayer();
|
|
||||||
|
|
||||||
public Level getLevel();
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
package tschipp.carryon.proxy;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
|
|
||||||
public class ServerProxy implements IProxy
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup(FMLCommonSetupEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Player getPlayer()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Level getLevel()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
16
src/main/resources/assets/carryon/lang/sv_se.json
Normal file
16
src/main/resources/assets/carryon/lang/sv_se.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"carryon.category.settings": "Inställningar",
|
||||||
|
"carryon.category.blacklist": "Svartlista",
|
||||||
|
"carryon.category.modeloverrides": "Åsidosättningar för modeller (avancerat)",
|
||||||
|
"carryon.category.custompickupconditions": "Anpassade villkor för att kunna plocka upp (avancerat)",
|
||||||
|
"carryon.category.whitelist": "Vitlista",
|
||||||
|
|
||||||
|
"carryon.general.modeloverrides.modeloverrides": "Åsidosättningar för modeller",
|
||||||
|
"carryon.general.blacklist.forbiddenentities": "Entiteter som spelare inte kan plocka upp",
|
||||||
|
"carryon.general.blacklist.forbiddentiles": "Block som spelare inte kan plocka upp",
|
||||||
|
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Anpassade villkor för att kunna plocka upp block",
|
||||||
|
"carryon.category.custompickupconditions.custompickupconditionsentities": "Anpassade villkor för att kunna plocka upp entiteter",
|
||||||
|
|
||||||
|
"key.carry.desc": "Plocka upp",
|
||||||
|
"key.carry.category": "Carry On"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user