Compare commits

...

10 Commits

Author SHA1 Message Date
Tschipp
058df989fc fixed bugs 2023-04-25 21:05:06 +02:00
Tschipp
308fc5c775 updated forge 2023-04-25 17:26:09 +02:00
Tschipp
bb7cdf33a6 fixed not saving boats and similar entities 2021-12-25 00:17:06 +01:00
Tschipp
aadba7fdc5 actually fixed javadoc 2021-12-23 23:39:20 +01:00
Tschipp
a6efe11226 fixed jenkinsfile 2021-12-23 23:36:51 +01:00
Tschipp
b1885bb39b updated forge, fixed bad names 2021-12-23 23:35:05 +01:00
Tschipp
f9a6265db9 Merge remote-tracking branch 'origin/1.16' into 1.16 2021-12-23 20:03:03 +01:00
Tschipp
eb533e0432 fixed javadoc 2021-12-23 20:03:01 +01:00
Tschipp
1c6aed635e
Merge pull request #297 from KnottyManatee55/patch-1
Russian translation
2021-12-23 17:25:44 +01:00
KhottyManatee55
01fb918cfc
Russian translation 2021-03-12 22:16:24 +03:00
21 changed files with 417 additions and 458 deletions

View File

@ -5,7 +5,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
} }
} }
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
@ -14,7 +14,7 @@ apply plugin: 'maven-publish'
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'
import net.minecraftforge.gradle.common.task.SignJar //import net.minecraftforge.gradle.common.task.SignJar
import groovy.json.JsonSlurper import groovy.json.JsonSlurper
import groovy.json.JsonOutput import groovy.json.JsonOutput
@ -26,8 +26,9 @@ version = "${version}"
group = "tschipp.carryon" group = "tschipp.carryon"
archivesBaseName = "carryon-${minecraft_version}" archivesBaseName = "carryon-${minecraft_version}"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' //sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
if (System.getenv('BUILD_NUMBER') != null) { if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER') version += "." + System.getenv('BUILD_NUMBER')
@ -215,6 +216,7 @@ publishing {
} }
} }
/*
task signJar(type: SignJar, dependsOn: jar) { task signJar(type: SignJar, dependsOn: jar) {
// Skips if the keyStore property is missing. // Skips if the keyStore property is missing.
onlyIf { onlyIf {
@ -230,7 +232,7 @@ task signJar(type: SignJar, dependsOn: jar) {
keyPass = project.findProperty('modkeyStoreKeyPass') keyPass = project.findProperty('modkeyStoreKeyPass')
inputFile = jar.archivePath inputFile = jar.archivePath
outputFile = jar.archivePath outputFile = jar.archivePath
} } */
// Runs this task automatically when build is ran. // Runs this task automatically when build is ran.
build.dependsOn signJar //build.dependsOn signJar

View File

@ -1,7 +1,7 @@
# 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.15.5 version=1.15.6
minecraft_version=1.16.5 minecraft_version=1.16.5
mcp_mappings=20201028-1.16.3 mcp_mappings=20201028-1.16.3
forge_version=36.0.22 forge_version=36.2.39

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip

View File

@ -1,16 +1,9 @@
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.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
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.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 +14,22 @@ import net.minecraftforge.fml.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel; import net.minecraftforge.fml.network.simple.SimpleChannel;
import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModInfo;
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;";
@ -72,12 +65,8 @@ public class CarryOn
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER)); CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
RegistrationHandler.regCommonEvents(); RegistrationHandler.regCommonEvents();
// Init
RegistrationHandler.regOverrideList();
RegistrationHandler.regCaps(); RegistrationHandler.regCaps();
RegistrationHandler.regOverrideList();
proxy.setup(event);
} }
@SubscribeEvent @SubscribeEvent

View File

@ -1,12 +1,9 @@
package tschipp.carryon.client.event; package tschipp.carryon.client.event;
import java.lang.reflect.InvocationTargetException; import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -14,6 +11,7 @@ import net.minecraft.client.GameSettings;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
@ -49,7 +47,6 @@ import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent.LoggedInEvent;
import net.minecraftforge.event.TickEvent.PlayerTickEvent; import net.minecraftforge.event.TickEvent.PlayerTickEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.EventPriority;
@ -60,7 +57,6 @@ import tschipp.carryon.CarryOn;
import tschipp.carryon.client.helper.CarryRenderHelper; import tschipp.carryon.client.helper.CarryRenderHelper;
import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.client.keybinds.CarryOnKeybinds;
import tschipp.carryon.common.config.Configs.Settings; import tschipp.carryon.common.config.Configs.Settings;
import tschipp.carryon.common.handler.ListHandler;
import tschipp.carryon.common.handler.ModelOverridesHandler; import tschipp.carryon.common.handler.ModelOverridesHandler;
import tschipp.carryon.common.handler.RegistrationHandler; import tschipp.carryon.common.handler.RegistrationHandler;
import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent; import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent;
@ -73,6 +69,10 @@ 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
{ {
/* /*
@ -242,7 +242,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);
@ -299,13 +299,13 @@ public class RenderEvents
matrix.popPose(); matrix.popPose();
} }
} }
// @SubscribeEvent // @SubscribeEvent
// public void onJoinServer(LoggedInEvent event) // public void onJoinServer(LoggedInEvent event)
// { // {
// ListHandler.initConfigLists(); // ListHandler.initConfigLists();
// } // }
/* /*
* Render blocks and entities in third person * Render blocks and entities in third person
@ -317,118 +317,128 @@ public class RenderEvents
{ {
World world = Minecraft.getInstance().level; World world = Minecraft.getInstance().level;
float partialticks = event.getPartialTicks(); float partialticks = event.getPartialTicks();
Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder());
MatrixStack matrix = event.getMatrixStack(); MatrixStack matrix = event.getMatrixStack();
int light = 0; int light = 0;
int perspective = CarryRenderHelper.getPerspective(); int perspective = CarryRenderHelper.getPerspective();
EntityRendererManager manager = Minecraft.getInstance().getEntityRenderDispatcher(); EntityRendererManager manager = Minecraft.getInstance().getEntityRenderDispatcher();
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.disableCull(); RenderSystem.disableCull();
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
Map<RenderType, BufferBuilder> builders = new ImmutableMap.Builder<RenderType, BufferBuilder>()
.put(RenderType.glint(), new BufferBuilder(RenderType.glint().bufferSize()))
.put(RenderType.glintDirect(), new BufferBuilder(RenderType.glintDirect().bufferSize()))
.put(RenderType.glintTranslucent(), new BufferBuilder(RenderType.glintTranslucent().bufferSize()))
.put(RenderType.entityGlint(), new BufferBuilder(RenderType.entityGlint().bufferSize()))
.put(RenderType.entityGlintDirect(), new BufferBuilder(RenderType.entityGlintDirect().bufferSize()))
.build();
Impl buffer = IRenderTypeBuffer.immediateWithBuffers(builders, Tessellator.getInstance().getBuilder());
for (PlayerEntity player : world.players())
{
if (perspective == 0 && player == Minecraft.getInstance().player)
continue;
light = Minecraft.getInstance().getEntityRenderDispatcher().getPackedLightCoords(player, partialticks); for (PlayerEntity player : world.players()) {
ItemStack stack = player.getMainHandItem(); try {
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) if (perspective == 0 && player == Minecraft.getInstance().player && !(ModList.get().isLoaded("firstperson") || ModList.get().isLoaded("firstpersonmod")))
{ continue;
Block block = ItemCarryonBlock.getBlock(stack);
BlockState state = ItemCarryonBlock.getBlockState(stack);
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
applyBlockTransformations(player, partialticks, matrix, block);
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileItem, world, player)); light = Minecraft.getInstance().getEntityRenderDispatcher().getPackedLightCoords(player, partialticks);
ItemStack stack = player.getMainHandItem();
CarryOnOverride carryOverride = ScriptChecker.getOverride(player); if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) {
if (carryOverride != null) Block block = ItemCarryonBlock.getBlock(stack);
{ BlockState state = ItemCarryonBlock.getBlockState(stack);
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride); CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
if (!carryOverride.getRenderNameBlock().isEmpty()) applyBlockTransformations(player, partialticks, matrix, block);
{
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
if (b != null)
{
ItemStack s = new ItemStack(b, 1);
s.setTag(carryOverride.getRenderNBT());
model = Minecraft.getInstance().getItemRenderer().getModel(s, world, player);
}
}
}
Minecraft.getInstance().getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS); IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileItem, world, player));
CarryRenderHelper.renderItem(state, tag, stack, tileItem, matrix, buffer, light, model);
buffer.endBatch();
matrix.popPose();
drawArms(player, partialticks, matrix, buffer, light);
matrix.popPose();
}
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
{
Entity entity = RenderEntityEvents.getEntity(stack, world);
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 = Minecraft.getInstance().getItemRenderer().getModel(s, world, player);
if (type.isPresent())
newEntity = type.get().create(world);
if (newEntity != null)
{
CompoundNBT nbttag = carryOverride.getRenderNBT();
if (nbttag != null)
newEntity.deserializeNBT(nbttag);
entity = newEntity;
entity.yRot = 0.0f;
entity.yRotO = 0.0f;
entity.setYHeadRot(0.0f);
entity.xRot = 0.0f;
entity.xRotO = 0.0f;
} }
} }
} }
if (entity instanceof LivingEntity) Minecraft.getInstance().getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS);
((LivingEntity) entity).hurtTime = 0; CarryRenderHelper.renderItem(state, tag, stack, tileItem, matrix, buffer, light, model);
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
buffer.endBatch(); buffer.endBatch();
matrix.popPose(); matrix.popPose();
drawArms(player, partialticks, matrix, buffer, light); drawArms(player, partialticks, matrix, buffer, light);
manager.setRenderShadow(true);
matrix.popPose(); matrix.popPose();
} } else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) {
} Entity entity = RenderEntityEvents.getEntity(stack, world);
if (entity != null) {
applyEntityTransformations(player, partialticks, matrix, entity);
manager.setRenderShadow(false);
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(world);
if (newEntity != null) {
CompoundNBT nbttag = carryOverride.getRenderNBT();
if (nbttag != null)
newEntity.deserializeNBT(nbttag);
entity = newEntity;
entity.yRot = 0.0f;
entity.yRotO = 0.0f;
entity.setYHeadRot(0.0f);
entity.xRot = 0.0f;
entity.xRotO = 0.0f;
}
}
}
if (entity instanceof LivingEntity)
((LivingEntity) entity).hurtTime = 0;
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
buffer.endBatch();
matrix.popPose();
drawArms(player, partialticks, matrix, buffer, light);
manager.setRenderShadow(true);
matrix.popPose();
}
}
} catch (Exception e) {
}
} }
buffer.endBatch();
buffer.endBatch(RenderType.entitySolid(AtlasTexture.LOCATION_BLOCKS));
buffer.endBatch(RenderType.entityCutout(AtlasTexture.LOCATION_BLOCKS));
buffer.endBatch(RenderType.entityCutoutNoCull(AtlasTexture.LOCATION_BLOCKS));
buffer.endBatch(RenderType.entitySmoothCutout(AtlasTexture.LOCATION_BLOCKS));
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
RenderSystem.enableCull(); RenderSystem.enableCull();
RenderSystem.disableBlend(); RenderSystem.disableBlend();

View File

@ -15,14 +15,12 @@ public class PositionProvider implements ICapabilitySerializable<CompoundNBT>
private IPosition instance = POSITION_CAPABILITY.getDefaultInstance(); private IPosition instance = POSITION_CAPABILITY.getDefaultInstance();
@SuppressWarnings("unchecked")
@Override @Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
{ {
if (cap == POSITION_CAPABILITY) if (cap == POSITION_CAPABILITY)
return (LazyOptional<T>) LazyOptional.of(() -> { return (LazyOptional<T>) LazyOptional.of(TEPosition::new);
return new TEPosition();
});
return LazyOptional.empty(); return LazyOptional.empty();
} }

View File

@ -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,9 +14,13 @@ import net.minecraftforge.fml.config.ModConfig;
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.Collections;
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 {
private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder();
@ -28,92 +28,90 @@ public class Configs {
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);
WhiteList.init(SERVER_BUILDER, CLIENT_BUILDER); WhiteList.init(SERVER_BUILDER, CLIENT_BUILDER);
ModelOverrides.init(SERVER_BUILDER, CLIENT_BUILDER); ModelOverrides.init(SERVER_BUILDER, CLIENT_BUILDER);
CustomPickupConditions.init(SERVER_BUILDER, CLIENT_BUILDER); CustomPickupConditions.init(SERVER_BUILDER, CLIENT_BUILDER);
SERVER_CONFIG = SERVER_BUILDER.build(); SERVER_CONFIG = SERVER_BUILDER.build();
CLIENT_CONFIG = CLIENT_BUILDER.build(); CLIENT_CONFIG = CLIENT_BUILDER.build();
} }
@SubscribeEvent @SubscribeEvent
public static void onLoad(final ModConfig.Loading event) public static void onLoad(final ModConfig.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();
if(cfg instanceof CommentedFileConfig) if(cfg instanceof CommentedFileConfig)
((CommentedFileConfig) cfg).load(); ((CommentedFileConfig) cfg).load();
} }
} }
@SubscribeEvent @SubscribeEvent
public static void onConfigChanged(ModConfig.Reloading event) public static void onConfigChanged(ModConfig.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();
if(cfg instanceof CommentedFileConfig) if(cfg instanceof CommentedFileConfig)
((CommentedFileConfig) cfg).load(); ((CommentedFileConfig) cfg).load();
} }
} }
public static class Settings public static class Settings
{ {
public static BooleanValue facePlayer; public static BooleanValue facePlayer;
public static BooleanValue heavyTiles; public static BooleanValue heavyTiles;
public static BooleanValue pickupAllBlocks; public static BooleanValue pickupAllBlocks;
public static BooleanValue slownessInCreative; public static BooleanValue slownessInCreative;
public static DoubleValue maxDistance; public static DoubleValue maxDistance;
public static DoubleValue maxEntityWidth; public static DoubleValue maxEntityWidth;
public static DoubleValue maxEntityHeight; public static DoubleValue maxEntityHeight;
public static BooleanValue pickupHostileMobs; public static BooleanValue pickupHostileMobs;
public static BooleanValue heavyEntities; public static BooleanValue heavyEntities;
public static DoubleValue blockSlownessMultiplier; public static DoubleValue blockSlownessMultiplier;
public static DoubleValue entitySlownessMultiplier; public static DoubleValue entitySlownessMultiplier;
public static BooleanValue renderArms; public static BooleanValue renderArms;
public static BooleanValue allowBabies; public static BooleanValue allowBabies;
public static BooleanValue useWhitelistBlocks; public static BooleanValue useWhitelistBlocks;
public static BooleanValue useWhitelistEntities; public static BooleanValue useWhitelistEntities;
public static BooleanValue useWhitelistStacking; public static BooleanValue useWhitelistStacking;
public static BooleanValue hitWhileCarrying; public static BooleanValue hitWhileCarrying;
public static BooleanValue dropCarriedWhenHit; public static BooleanValue dropCarriedWhenHit;
public static BooleanValue useScripts; public static BooleanValue useScripts;
public static BooleanValue stackableEntities; public static BooleanValue stackableEntities;
public static IntValue maxEntityStackLimit; public static IntValue maxEntityStackLimit;
public static BooleanValue entitySizeMattersStacking; public static BooleanValue entitySizeMattersStacking;
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
{ {
c.comment("Settings"); c.comment("Settings");
@ -121,336 +119,324 @@ public class Configs {
s.push("settings"); s.push("settings");
c.push("settings"); c.push("settings");
maxDistance = s maxDistance = s
.comment("Maximum distance from where Blocks and Entities can be picked up") .comment("Maximum distance from where Blocks and Entities can be picked up")
.defineInRange("maxDistance", 2.5, 0, Double.MAX_VALUE); .defineInRange("maxDistance", 2.5, 0, Double.MAX_VALUE);
maxEntityWidth = s maxEntityWidth = s
.comment("Max width of entities that can be picked up in survival mode") .comment("Max width of entities that can be picked up in survival mode")
.defineInRange("maxEntityWidth", 1.5, 0, 10); .defineInRange("maxEntityWidth", 1.5, 0, 10);
maxEntityHeight = s maxEntityHeight = s
.comment("Max height of entities that can be picked up in survival mode") .comment("Max height of entities that can be picked up in survival mode")
.defineInRange("maxEntityHeight", 1.5, 0, 10); .defineInRange("maxEntityHeight", 1.5, 0, 10);
maxEntityWidth = s maxEntityWidth = s
.comment("Max width of entities that can be picked up in survival mode") .comment("Max width of entities that can be picked up in survival mode")
.defineInRange("maxEntityWidth", 1.5, 0, 10); .defineInRange("maxEntityWidth", 1.5, 0, 10);
blockSlownessMultiplier = s blockSlownessMultiplier = s
.comment("Slowness multiplier for blocks") .comment("Slowness multiplier for blocks")
.defineInRange("blockSlownessMultiplier", 1, 0, Double.MAX_VALUE); .defineInRange("blockSlownessMultiplier", 1, 0, Double.MAX_VALUE);
entitySlownessMultiplier = s entitySlownessMultiplier = s
.comment("Slowness multiplier for entities") .comment("Slowness multiplier for entities")
.defineInRange("entitySlownessMultiplier", 1, 0, Double.MAX_VALUE); .defineInRange("entitySlownessMultiplier", 1, 0, Double.MAX_VALUE);
maxEntityStackLimit = s maxEntityStackLimit = s
.comment("Maximum stack limit for entities") .comment("Maximum stack limit for entities")
.defineInRange("maxEntityStackLimit", 10, 1, Integer.MAX_VALUE); .defineInRange("maxEntityStackLimit", 10, 1, Integer.MAX_VALUE);
facePlayer = c facePlayer = c
.comment("If the front of the Tile Entities should face the player or should face outward") .comment("If the front of the Tile Entities should face the player or should face outward")
.define("facePlayer", false); .define("facePlayer", false);
heavyTiles = s heavyTiles = s
.comment("More complex Tile Entities slow down the player more") .comment("More complex Tile Entities slow down the player more")
.define("heavyTiles", true); .define("heavyTiles", true);
pickupAllBlocks = s pickupAllBlocks = s
.comment("Allow all blocks to be picked up, not just Tile Entites") .comment("Allow all blocks to be picked up, not just Tile Entites")
.define("pickupAllBlocks", false); .define("pickupAllBlocks", false);
slownessInCreative = s slownessInCreative = s
.comment("Whether Blocks and Entities slow the creative player down when carried") .comment("Whether Blocks and Entities slow the creative player down when carried")
.define("slownessInCreative", true); .define("slownessInCreative", true);
pickupHostileMobs = s pickupHostileMobs = s
.comment("Whether hostile mobs should be able to picked up in survival mode") .comment("Whether hostile mobs should be able to picked up in survival mode")
.define("pickupHostileMobs", false); .define("pickupHostileMobs", false);
heavyEntities = s heavyEntities = s
.comment("Larger Entities slow down the player more") .comment("Larger Entities slow down the player more")
.define("heavyEntities", true); .define("heavyEntities", true);
renderArms = c renderArms = c
.comment("Arms should render on sides when carrying") .comment("Arms should render on sides when carrying")
.define("renderArms", true); .define("renderArms", true);
allowBabies = s allowBabies = s
.comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)") .comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)")
.define("allowBabies", false); .define("allowBabies", false);
useWhitelistBlocks = s useWhitelistBlocks = s
.comment("Use Whitelist instead of Blacklist for Blocks") .comment("Use Whitelist instead of Blacklist for Blocks")
.define("useWhitelistBlocks", false); .define("useWhitelistBlocks", false);
useWhitelistEntities = s useWhitelistEntities = s
.comment("Use Whitelist instead of Blacklist for Entities") .comment("Use Whitelist instead of Blacklist for Entities")
.define("useWhitelistEntities", false); .define("useWhitelistEntities", false);
useWhitelistStacking = s useWhitelistStacking = s
.comment("Use Whitelist instead of Blacklist for Stacking") .comment("Use Whitelist instead of Blacklist for Stacking")
.define("useWhitelistStacking", false); .define("useWhitelistStacking", false);
hitWhileCarrying = s hitWhileCarrying = s
.comment("Whether the player can hit blocks and entities while carrying or not") .comment("Whether the player can hit blocks and entities while carrying or not")
.define("hitWhileCarrying", false); .define("hitWhileCarrying", false);
dropCarriedWhenHit = s dropCarriedWhenHit = s
.comment("Whether the player drops the carried object when hit or not") .comment("Whether the player drops the carried object when hit or not")
.define("dropCarriedWhenHit", false); .define("dropCarriedWhenHit", false);
useScripts = s useScripts = s
.comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance") .comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance")
.worldRestart() .worldRestart()
.define("useScripts", false); .define("useScripts", false);
stackableEntities = s stackableEntities = s
.comment("Allows entities to be stacked using Carry On") .comment("Allows entities to be stacked using Carry On")
.define("stackableEntities", true); .define("stackableEntities", true);
entitySizeMattersStacking = s entitySizeMattersStacking = s
.comment("Whether entities' size matters when stacking or not") .comment("Whether entities' size matters when stacking or not")
.define("stackableEntities", true); .define("stackableEntities", true);
s.pop(); s.pop();
c.pop(); c.pop();
} }
} }
public static class WhiteList public static class WhiteList
{ {
public static ConfigValue<List<? extends String>> allowedEntities; public static ConfigValue<List<? extends String>> allowedEntities;
public static ConfigValue<List<? extends String>> allowedBlocks; public static ConfigValue<List<? extends String>> allowedBlocks;
public static ConfigValue<List<? extends String>> allowedStacking; public static ConfigValue<List<? extends String>> allowedStacking;
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
{ {
s.comment("Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"); s.comment("Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
allowedEntities = s allowedEntities = s
.comment("Entities that CAN be picked up (useWhitelistEntities must be true)") .comment("Entities that CAN be picked up (useWhitelistEntities must be true)")
.defineList("whitelist.allowedEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false); .defineList("whitelist.allowedEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String);
allowedBlocks = s allowedBlocks = s
.comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)") .comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)")
.defineList("whitelist.allowedBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false); .defineList("whitelist.allowedBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String);
allowedStacking = s allowedStacking = s
.comment("Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)") .comment("Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)")
.defineList("whitelist.allowedStacking", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false); .defineList("whitelist.allowedStacking", Arrays.asList(new String[]{}), (obj) -> obj instanceof String);
} }
} }
public static class Blacklist public static class Blacklist
{ {
public static ConfigValue<List<? extends String>> forbiddenTiles; public static ConfigValue<List<? extends String>> forbiddenTiles;
public static ConfigValue<List<? extends String>> forbiddenEntities; public static ConfigValue<List<? extends String>> forbiddenEntities;
public static ConfigValue<List<? extends String>> forbiddenStacking; public static ConfigValue<List<? extends String>> forbiddenStacking;
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
{ {
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 forbiddenTiles = s
.comment("Blocks that cannot be picked up") .comment("Blocks that cannot be picked up")
.defineList("blacklist.forbiddenTiles", Arrays.asList(new String[] .defineList("blacklist.forbiddenTiles", Arrays.asList("#forge:immovable",
{ "#forge:relocation_not_supported",
"#forge:immovable", "minecraft:end_portal",
"#forge:relocation_not_supported", "minecraft:end_gateway",
"minecraft:end_portal", "minecraft:tall_grass",
"minecraft:end_gateway", "minecraft:large_fern",
"minecraft:tall_grass", "minecraft:peony",
"minecraft:large_fern", "minecraft:rose_bush",
"minecraft:peony", "minecraft:lilac",
"minecraft:rose_bush", "minecraft:sunflower",
"minecraft:lilac", "minecraft:*_bed",
"minecraft:sunflower", "minecraft:oak_door",
"minecraft:*_bed", "minecraft:iron_door",
"minecraft:oak_door", "minecraft:spruce_door",
"minecraft:iron_door", "minecraft:birch_door",
"minecraft:spruce_door", "minecraft:jungle_door",
"minecraft:birch_door", "minecraft:acacia_door",
"minecraft:jungle_door", "minecraft:dark_oak_door",
"minecraft:acacia_door", "minecraft:waterlily",
"minecraft:dark_oak_door", "minecraft:cake",
"minecraft:waterlily", "minecraft:nether_portal",
"minecraft:cake", "minecraft:tall_seagrass",
"minecraft:nether_portal", "animania:block_trough",
"minecraft:tall_seagrass", "animania:block_invisiblock",
"animania:block_trough", "colossalchests:*",
"animania:block_invisiblock", "ic2:*",
"colossalchests:*", "bigreactors:*",
"ic2:*", "forestry:*",
"bigreactors:*", "tconstruct:*",
"forestry:*", "rustic:*",
"tconstruct:*", "botania:*",
"rustic:*", "astralsorcery:*",
"botania:*", "quark:colored_bed_*",
"astralsorcery:*", "immersiveengineering:*",
"quark:colored_bed_*", "embers:block_furnace",
"immersiveengineering:*", "embers:ember_bore",
"embers:block_furnace", "embers:ember_activator",
"embers:ember_bore", "embers:mixer",
"embers:ember_activator", "embers:heat_coil",
"embers:mixer", "embers:large_tank",
"embers:heat_coil", "embers:crystal_cell",
"embers:large_tank", "embers:alchemy_pedestal",
"embers:crystal_cell", "embers:boiler",
"embers:alchemy_pedestal", "embers:combustor",
"embers:boiler", "embers:catalzyer",
"embers:combustor", "embers:field_chart",
"embers:catalzyer", "embers:inferno_forge",
"embers:field_chart", "storagedrawers:framingtable",
"embers:inferno_forge", "skyresources:*",
"storagedrawers:framingtable", "lootbags:*",
"skyresources:*", "exsartagine:*",
"lootbags:*", "aquamunda:tank",
"exsartagine:*", "opencomputers:*",
"aquamunda:tank", "malisisdoors:*",
"opencomputers:*", "industrialforegoing:*",
"malisisdoors:*", "minecolonies:*",
"industrialforegoing:*", "thaumcraft:pillar*",
"minecolonies:*", "thaumcraft:infernal_furnace",
"thaumcraft:pillar*", "thaumcraft:placeholder*",
"thaumcraft:infernal_furnace", "thaumcraft:infusion_matrix",
"thaumcraft:placeholder*", "thaumcraft:golem_builder",
"thaumcraft:infusion_matrix", "thaumcraft:thaumatorium*",
"thaumcraft:golem_builder", "magneticraft:oil_heater",
"thaumcraft:thaumatorium*", "magneticraft:solar_panel",
"magneticraft:oil_heater", "magneticraft:steam_engine",
"magneticraft:solar_panel", "magneticraft:shelving_unit",
"magneticraft:steam_engine", "magneticraft:grinder",
"magneticraft:shelving_unit", "magneticraft:sieve",
"magneticraft:grinder", "magneticraft:solar_tower",
"magneticraft:sieve", "magneticraft:solar_mirror",
"magneticraft:solar_tower", "magneticraft:container",
"magneticraft:solar_mirror", "magneticraft:pumpjack",
"magneticraft:container", "magneticraft:solar_panel",
"magneticraft:pumpjack", "magneticraft:refinery",
"magneticraft:solar_panel", "magneticraft:oil_heater",
"magneticraft:refinery", "magneticraft:hydraulic_press",
"magneticraft:oil_heater", "magneticraft:multiblock_gap",
"magneticraft:hydraulic_press", "refinedstorage:*",
"magneticraft:multiblock_gap", "mcmultipart:*",
"refinedstorage:*", "enderstorage:*",
"mcmultipart:*", "betterstorage:*",
"enderstorage:*", "practicallogistics2:*",
"betterstorage:*", "wearablebackpacks:*",
"practicallogistics2:*", "rftools:screen",
"wearablebackpacks:*", "rftools:creative_screen",
"rftools:screen", "create:*",
"rftools:creative_screen", "magic_doorknob:*",
"create:*", "iceandfire:*",
"magic_doorknob:*", "ftbquests:*",
"iceandfire:*", "waystones:*",
"ftbquests:*", "framedblocks:*", "securitycraft:*", "forgemultipartcbe:*", "integrateddynamics:cable", "tanknull:*"), (obj) -> obj instanceof String);
"waystones:*"
}), (obj) -> obj instanceof String);
forbiddenEntities = s forbiddenEntities = s
.comment("Entities that cannot be picked up") .comment("Entities that cannot be picked up")
.defineList("blacklist.forbiddenEntities", Arrays.asList(new String[] .defineList("blacklist.forbiddenEntities", Arrays.asList("minecraft:end_crystal",
{ "minecraft:ender_dragon",
"minecraft:end_crystal", "minecraft:ghast",
"minecraft:ender_dragon", "minecraft:shulker",
"minecraft:ghast", "minecraft:leash_knot",
"minecraft:shulker", "minecraft:armor_stand",
"minecraft:leash_knot", "minecraft:item_frame",
"minecraft:armor_stand", "minecraft:painting",
"minecraft:item_frame", "minecraft:shulker_bullet",
"minecraft:painting", "animania:hamster",
"minecraft:shulker_bullet", "animania:ferret*",
"animania:hamster", "animania:hedgehog*",
"animania:ferret*", "animania:cart",
"animania:hedgehog*", "animania:wagon",
"animania:cart", "mynko:*",
"animania:wagon", "pixelmon:*",
"mynko:*", "mocreatures:*",
"pixelmon:*", "quark:totem",
"mocreatures:*", "vehicle:*",
"quark:totem", "securitycraft:*", "taterzens:npc", "easy_npc:*", "minecolonies:*"), (obj) -> obj instanceof String);
"vehicle:*"
}), (obj) -> obj instanceof String ? true : false);
forbiddenStacking = s forbiddenStacking = s
.comment("Entities that cannot have other entities stacked on top of them") .comment("Entities that cannot have other entities stacked on top of them")
.defineList("blacklist.forbiddenStacking", Arrays.asList(new String[] .defineList("blacklist.forbiddenStacking", Arrays.asList("minecraft:horse"), (obj) -> obj instanceof String);
{
"minecraft:horse"
}), (obj) -> obj instanceof String ? true : false);
} }
} }
public static class ModelOverrides public static class ModelOverrides
{ {
public static ConfigValue<List<? extends String>> modelOverrides; public static ConfigValue<List<? extends String>> modelOverrides;
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
{ {
c.comment("Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config"); c.comment("Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config");
modelOverrides = c modelOverrides = c
.comment("Model Overrides based on NBT or on Meta. Advanced Users Only!") .comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
.defineList("modeloverrides.overrides", Arrays.asList(new String[] .defineList("modeloverrides.overrides", Arrays.asList("minecraft:hopper->(block)minecraft:hopper",
{ "minecraft:comparator->(block)minecraft:comparator",
"minecraft:hopper->(block)minecraft:hopper", "minecraft:repeater->(block)minecraft:repeater",
"minecraft:comparator->(block)minecraft:comparator", "minecraft:cauldron->(block)minecraft:cauldron",
"minecraft:repeater->(block)minecraft:repeater", "minecraft:brewing_stand->(item)minecraft:brewing_stand",
"minecraft:cauldron->(block)minecraft:cauldron", "minecraft:flower_pot->(block)minecraft:flower_pot",
"minecraft:brewing_stand->(item)minecraft:brewing_stand", "minecraft:sugar_cane->(block)minecraft:sugar_cane",
"minecraft:flower_pot->(block)minecraft:flower_pot", "minecraft:redstone_wire->(item)minecraft:redstone",
"minecraft:sugar_cane->(block)minecraft:sugar_cane", "animania:block_nest->(block)animania:block_nest",
"minecraft:redstone_wire->(item)minecraft:redstone", "animania:cheese_mold;0->(block)animania:cheese_mold;0",
"animania:block_nest->(block)animania:block_nest", "animania:cheese_mold;1->(block)animania:cheese_mold;1",
"animania:cheese_mold;0->(block)animania:cheese_mold;0", "animania:cheese_mold;2->(block)animania:cheese_mold;2",
"animania:cheese_mold;1->(block)animania:cheese_mold;1", "animania:cheese_mold;3->(block)animania:cheese_mold;3",
"animania:cheese_mold;2->(block)animania:cheese_mold;2", "animania:cheese_mold;4->(block)animania:cheese_mold;4",
"animania:cheese_mold;3->(block)animania:cheese_mold;3", "animania:cheese_mold;5->(block)animania:cheese_mold;5",
"animania:cheese_mold;4->(block)animania:cheese_mold;4", "animania:cheese_mold;6->(block)animania:cheese_mold;6",
"animania:cheese_mold;5->(block)animania:cheese_mold;5", "animania:cheese_mold;7->(block)animania:cheese_mold;7",
"animania:cheese_mold;6->(block)animania:cheese_mold;6", "animania:cheese_mold;8->(block)animania:cheese_mold;8",
"animania:cheese_mold;7->(block)animania:cheese_mold;7", "animania:cheese_mold;9->(block)animania:cheese_mold;9",
"animania:cheese_mold;8->(block)animania:cheese_mold;8", "animania:cheese_mold;10->(block)animania:cheese_mold;10"), (obj) -> obj instanceof String);
"animania:cheese_mold;9->(block)animania:cheese_mold;9",
"animania:cheese_mold;10->(block)animania:cheese_mold;10",
}), (obj) -> obj instanceof String ? true : false);
} }
} }
public static class CustomPickupConditions public static class CustomPickupConditions
{ {
public static ConfigValue<List<? extends String>> customPickupConditionsBlocks; public static ConfigValue<List<? extends String>> customPickupConditionsBlocks;
public static ConfigValue<List<? extends String>> customPickupConditionsEntities; public static ConfigValue<List<? extends String>> customPickupConditionsEntities;
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
{ {
s.comment("Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config"); s.comment("Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config");
customPickupConditionsBlocks = s customPickupConditionsBlocks = s
.comment("Custom Pickup Conditions for Blocks") .comment("Custom Pickup Conditions for Blocks")
.defineList("custom_pickup_conditions.customPickupConditionsBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false); .defineList("custom_pickup_conditions.customPickupConditionsBlocks", Collections.emptyList(), (obj) -> obj instanceof String);
customPickupConditionsEntities = s customPickupConditionsEntities = s
.comment("Custom Pickup Conditions for Entities") .comment("Custom Pickup Conditions for Entities")
.defineList("custom_pickup_conditions.customPickupConditionsEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false); .defineList("custom_pickup_conditions.customPickupConditionsEntities", Collections.emptyList(), (obj) -> obj instanceof String);
} }
} }

View File

@ -77,7 +77,7 @@ public class ItemEvents
{ {
player.getPersistentData().remove("carrySlot"); player.getPersistentData().remove("carrySlot");
event.setUseBlock(Result.DENY); event.setUseBlock(Result.DENY);
if (!player.level.isClientSide) if (!player.level.isClientSide)
{ {
CarryOnOverride override = ScriptChecker.getOverride(player); CarryOnOverride override = ScriptChecker.getOverride(player);
@ -92,7 +92,7 @@ public class ItemEvents
} }
} }
@SubscribeEvent(priority = EventPriority.HIGH) @SubscribeEvent(priority = EventPriority.HIGH)
public void onItemDropped(EntityJoinWorldEvent event) public void onItemDropped(EntityJoinWorldEvent event)
{ {
@ -141,7 +141,7 @@ public class ItemEvents
} }
} }
@SubscribeEvent @SubscribeEvent
public void onPlayerLogin(PlayerLoggedInEvent event) public void onPlayerLogin(PlayerLoggedInEvent event)
{ {
@ -184,17 +184,18 @@ public class ItemEvents
{ {
CommandCarryOn.register(event.getDispatcher()); CommandCarryOn.register(event.getDispatcher());
} }
@SubscribeEvent @SubscribeEvent
public void serverLoad(FMLServerStartingEvent event) public void serverLoad(FMLServerStartingEvent event)
{ {
CustomPickupOverrideHandler.initPickupOverrides(); CustomPickupOverrideHandler.initPickupOverrides();
} }
@SubscribeEvent @SubscribeEvent
public void reloadTags(TagsUpdatedEvent event) public void reloadTags(TagsUpdatedEvent event)
{ {
ListHandler.initConfigLists(); ListHandler.initConfigLists();
CustomPickupOverrideHandler.initPickupOverrides();
} }
@SubscribeEvent @SubscribeEvent
@ -292,7 +293,7 @@ public class ItemEvents
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
{ {
PlayerEntity player = event.getPlayer(); PlayerEntity player = event.getPlayer();
if(event.isCanceled()) if(event.isCanceled())
return; return;
@ -484,8 +485,8 @@ public class ItemEvents
int slotBlock = getSlot(player, RegistrationHandler.itemTile); int slotBlock = getSlot(player, RegistrationHandler.itemTile);
int slotEntity = getSlot(player, RegistrationHandler.itemEntity); int slotEntity = getSlot(player, RegistrationHandler.itemEntity);
ItemEntity item = null; ItemEntity item = null;
if (slotBlock != -1) if (slotBlock != -1)
{ {

View File

@ -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.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -18,14 +14,17 @@ import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.GameType; import net.minecraft.world.GameType;
import net.minecraft.world.World; import net.minecraft.world.World;
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.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
{ {
@ -192,11 +191,14 @@ public class PickupHandler
} }
} }
public static class PickUpEntityEvent extends AttackEntityEvent public static class PickUpEntityEvent extends Event
{ {
public final PlayerEntity player;
public final Entity target;
public PickUpEntityEvent(PlayerEntity player, Entity target) public PickUpEntityEvent(PlayerEntity player, Entity target)
{ {
super(player, target); this.player = player;
this.target = target;
} }
} }

View File

@ -41,7 +41,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()

View File

@ -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
{ {

View File

@ -16,19 +16,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
*/ */
public class ReflectionUtil public class ReflectionUtil
{ {
/**
* Get a {@link MethodHandle} for a method.
*
* @param clazz
* The class
* @param methodNames
* The possible names of the method
* @param methodTypes
* The argument types of the method
* @param <T>
* The class
* @return The MethodHandle
*/
public static MethodHandle findMethod(final Class<?> clazz, final String methodName, @Nullable final String methodObfName, final Class<?>... parameterTypes) public static MethodHandle findMethod(final Class<?> clazz, final String methodName, @Nullable final String methodObfName, final Class<?>... parameterTypes)
{ {
final Method method = ObfuscationReflectionHelper.findMethod(clazz, methodName, parameterTypes); final Method method = ObfuscationReflectionHelper.findMethod(clazz, methodName, parameterTypes);

View File

@ -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

View File

@ -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.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -42,6 +37,9 @@ 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
{ {
@ -187,7 +185,11 @@ public class ItemCarryonBlock extends Item
{ {
CompoundNBT data = getTileData(stack); CompoundNBT data = getTileData(stack);
updateTileLocation(data, pos2); updateTileLocation(data, pos2);
tile.load(actualState, data); try {
tile.load(actualState, data);
}
catch (Exception e)
{}
} }
clearTileData(stack); clearTileData(stack);
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f); player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);

View File

@ -190,11 +190,19 @@ public class ItemCarryonEntity extends Item {
{ {
try try
{ {
initGoals.invoke(entity); if (entity instanceof MobEntity)
initGoals.invoke(entity);
entity.deserializeNBT(e); entity.deserializeNBT(e);
} }
catch (Exception e1) catch (Exception e1)
{ {
try
{
entity.deserializeNBT(e);
}
catch (Exception e2)
{
}
} }
} }

View File

@ -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.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.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(() -> {
World world = CarryOn.proxy.getWorld(); World world = ClientProxy.getWorld();
if (world != null) if (world != null)
{ {

View File

@ -3,35 +3,38 @@ package tschipp.carryon.proxy;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
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 {
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD, value = Dist.CLIENT)
@Override public class ClientProxy
public void setup(FMLCommonSetupEvent event) {
@SubscribeEvent
public static void setup(FMLClientSetupEvent event)
{ {
RegistrationHandler.regClientEvents(); RegistrationHandler.regClientEvents();
CarryOnKeybinds.init(); CarryOnKeybinds.init();
new ScrollCallbackWrapper().setup(Minecraft.getInstance());; new ScrollCallbackWrapper().setup(Minecraft.getInstance());
new KeyboardCallbackWrapper().setup(Minecraft.getInstance()); new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
} }
@Override public static PlayerEntity getPlayer()
public PlayerEntity getPlayer()
{ {
return Minecraft.getInstance().player; return Minecraft.getInstance().player;
} }
@Override public static World getWorld()
public World getWorld()
{ {
return Minecraft.getInstance().level; return Minecraft.getInstance().level;
} }

View File

@ -1,15 +0,0 @@
package tschipp.carryon.proxy;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
public interface IProxy
{
public void setup(final FMLCommonSetupEvent event);
public PlayerEntity getPlayer();
public World getWorld();
}

View File

@ -1,28 +0,0 @@
package tschipp.carryon.proxy;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
public class ServerProxy implements IProxy
{
@Override
public void setup(FMLCommonSetupEvent event)
{
}
@Override
public PlayerEntity getPlayer()
{
return null;
}
@Override
public World getWorld()
{
return null;
}
}

View File

@ -0,0 +1,16 @@
{
"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.carry.category": "Carry On"
}