Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afd9e8ac65 | ||
|
|
ac5f9447db | ||
|
|
e01cc75e5d | ||
|
|
e1da67a250 | ||
|
|
1e5adfdc27 | ||
|
|
3241c1b090 | ||
|
|
0d36a04c5b | ||
|
|
7785b39f7f | ||
|
|
ad67da7535 | ||
|
|
ad46b60e23 |
24
build.gradle
24
build.gradle
|
|
@ -20,8 +20,6 @@ apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Co
|
|||
apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle'
|
||||
|
||||
//import net.minecraftforge.gradle.common.task.SignJar
|
||||
import groovy.json.JsonSlurper
|
||||
import groovy.json.JsonOutput
|
||||
|
||||
if (project.hasProperty('secretFile')) {
|
||||
loadSecrets(new File((String) findProperty('secretFile')))
|
||||
|
|
@ -117,19 +115,19 @@ repositories {
|
|||
dependencies {
|
||||
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.bookshelf:Bookshelf-1.16.4:9.3.18")
|
||||
implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.18.2:8.1.3")
|
||||
implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.18.2:13.2.53")
|
||||
//implementation fg.deobf("curse.maven:obfuscate-289380:3169370")
|
||||
|
||||
//fileTree("libs").matching {
|
||||
// include "*.jar"
|
||||
//}.each {
|
||||
// String filename = it.getName();
|
||||
// filename = filename.substring(0, filename.length() - 4);
|
||||
// int lastDash = filename.lastIndexOf("-");
|
||||
// filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||
// implementation fg.deobf("blank:${filename}")
|
||||
//}
|
||||
fileTree("libs").matching {
|
||||
include "*.jar"
|
||||
}.each {
|
||||
String filename = it.getName();
|
||||
filename = filename.substring(0, filename.length() - 4);
|
||||
int lastDash = filename.lastIndexOf("-");
|
||||
filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||
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.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
version=1.17.0
|
||||
version=1.17.2
|
||||
minecraft_version=1.18.2
|
||||
mappings_version=2022.02.13-1.18.1
|
||||
forge_version=40.0.3
|
||||
mappings_version=2022.09.04-1.18.2
|
||||
forge_version=40.2.14
|
||||
org.gradle.daemon=false
|
||||
# chorg.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-17.0.1/
|
||||
|
|
@ -1,16 +1,10 @@
|
|||
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.world.item.Item;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
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.common.Mod;
|
||||
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.NetworkRegistry;
|
||||
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.handler.RegistrationHandler;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||
import tschipp.carryon.proxy.ClientProxy;
|
||||
import tschipp.carryon.proxy.IProxy;
|
||||
import tschipp.carryon.proxy.ServerProxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mod(CarryOn.MODID)
|
||||
@EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class CarryOn
|
||||
{
|
||||
|
||||
public static IProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
||||
|
||||
public static final String MODID = "carryon";
|
||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
|
||||
|
|
@ -75,8 +69,6 @@ public class CarryOn
|
|||
|
||||
// Init
|
||||
RegistrationHandler.regOverrideList();
|
||||
|
||||
proxy.setup(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class RenderEntityEvents
|
|||
|
||||
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;
|
||||
|
||||
Entity entity = getEntity(stack, level);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
package tschipp.carryon.client.event;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
@ -71,8 +68,22 @@ import tschipp.carryon.common.scripting.CarryOnOverride;
|
|||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
|
|
@ -165,7 +176,8 @@ public class RenderEvents
|
|||
|
||||
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().mouseHandler.grabMouse();
|
||||
|
||||
|
|
@ -243,7 +255,7 @@ public class RenderEvents
|
|||
|
||||
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;
|
||||
|
||||
Block block = ItemCarryonBlock.getBlock(stack);
|
||||
|
|
@ -318,7 +330,6 @@ public class RenderEvents
|
|||
Minecraft mc = Minecraft.getInstance();
|
||||
Level level = mc.level;
|
||||
float partialticks = event.getPartialTick();
|
||||
BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
int light = 0;
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
|
|
@ -327,17 +338,20 @@ public class RenderEvents
|
|||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableDepthTest();
|
||||
BufferSource buffer = MultiBufferSource.immediateWithBuffers(builders, Tesselator.getInstance().getBuilder());
|
||||
|
||||
|
||||
for (Player player : level.players())
|
||||
{
|
||||
if (perspective == 0 && player == mc.player)
|
||||
try {
|
||||
|
||||
if (perspective == 0 && player == mc.player && !(ModList.get().isLoaded("firstperson") || ModList.get().isLoaded("firstpersonmod")))
|
||||
continue;
|
||||
|
||||
light = manager.getPackedLightCoords(player, partialticks);
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||
{
|
||||
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);
|
||||
|
|
@ -348,15 +362,12 @@ public class RenderEvents
|
|||
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);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
if (carryOverride != null) {
|
||||
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||
|
||||
if (!carryOverride.getRenderNameBlock().isEmpty())
|
||||
{
|
||||
if (!carryOverride.getRenderNameBlock().isEmpty()) {
|
||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||
if (b != null)
|
||||
{
|
||||
if (b != null) {
|
||||
ItemStack s = new ItemStack(b, 1);
|
||||
s.setTag(carryOverride.getRenderNBT());
|
||||
model = mc.getItemRenderer().getModel(s, level, player, 0);
|
||||
|
|
@ -379,33 +390,27 @@ public class RenderEvents
|
|||
buffer.endBatch();
|
||||
|
||||
matrix.popPose();
|
||||
}
|
||||
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
{
|
||||
} else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) {
|
||||
Entity entity = RenderEntityEvents.getEntity(stack, level);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
if (entity != null) {
|
||||
applyEntityTransformations(player, partialticks, matrix, entity);
|
||||
|
||||
manager.setRenderShadow(false);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
if (carryOverride != null) {
|
||||
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||
|
||||
String entityname = carryOverride.getRenderNameEntity();
|
||||
if (entityname != null)
|
||||
{
|
||||
if (entityname != null) {
|
||||
Entity newEntity = null;
|
||||
|
||||
Optional<EntityType<?>> type = EntityType.byString(entityname);
|
||||
if (type.isPresent())
|
||||
newEntity = type.get().create(level);
|
||||
|
||||
if (newEntity != null)
|
||||
{
|
||||
if (newEntity != null) {
|
||||
CompoundTag nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.deserializeNBT(nbttag);
|
||||
|
|
@ -425,7 +430,6 @@ public class RenderEvents
|
|||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||
buffer.endBatch();
|
||||
|
||||
matrix.popPose();
|
||||
|
||||
|
|
@ -436,8 +440,19 @@ public class RenderEvents
|
|||
matrix.popPose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
buffer.endLastBatch();
|
||||
|
||||
buffer.endBatch(RenderType.entitySolid(TextureAtlas.LOCATION_BLOCKS));
|
||||
buffer.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS));
|
||||
buffer.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS));
|
||||
buffer.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS));
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.disableBlend();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
package tschipp.carryon.common.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
|
|
@ -18,6 +14,9 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD)
|
||||
public class Configs
|
||||
{
|
||||
|
|
@ -28,8 +27,7 @@ public class Configs
|
|||
public static final ForgeConfigSpec SERVER_CONFIG;
|
||||
public static final ForgeConfigSpec CLIENT_CONFIG;
|
||||
|
||||
static
|
||||
{
|
||||
static {
|
||||
|
||||
Settings.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
|
|
@ -44,8 +42,7 @@ public class Configs
|
|||
@SubscribeEvent
|
||||
public static void onLoad(final ModConfigEvent.Loading event)
|
||||
{
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID)) {
|
||||
ListHandler.initConfigLists();
|
||||
|
||||
CommentedConfig cfg = event.getConfig().getConfigData();
|
||||
|
|
@ -58,8 +55,7 @@ public class Configs
|
|||
@SubscribeEvent
|
||||
public static void onConfigChanged(ModConfigEvent.Reloading event)
|
||||
{
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID)) {
|
||||
ListHandler.initConfigLists();
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
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");
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,38 @@
|
|||
package tschipp.carryon.common.event;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.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.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@EventBusSubscriber(modid = CarryOn.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class IMCEvents
|
||||
{
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void serverLoad(FMLDedicatedServerSetupEvent event)
|
||||
public static void serverLoad(InterModProcessEvent event)
|
||||
{
|
||||
Stream<IMCMessage> messages = InterModComms.getMessages(CarryOn.MODID);
|
||||
|
||||
messages.forEach(msg -> {
|
||||
|
||||
ListHandler.IMCMessages.add(() -> {
|
||||
String method = msg.method();
|
||||
Object obj = msg.messageSupplier().get();
|
||||
|
||||
if (!(obj instanceof String str))
|
||||
return;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
switch (method) {
|
||||
case "blacklistBlock":
|
||||
ListHandler.FORBIDDEN_TILES.add(str);
|
||||
break;
|
||||
|
|
@ -53,6 +57,7 @@ public class IMCEvents
|
|||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package tschipp.carryon.common.event;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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.ScriptReloadPacket;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@EventBusSubscriber(modid = CarryOn.MODID)
|
||||
public class ItemEvents
|
||||
{
|
||||
|
|
@ -196,6 +196,7 @@ public class ItemEvents
|
|||
public void reloadTags(TagsUpdatedEvent event)
|
||||
{
|
||||
ListHandler.initConfigLists();
|
||||
CustomPickupOverrideHandler.initPickupOverrides();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -1,20 +1,23 @@
|
|||
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.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.Configs.Blacklist;
|
||||
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 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<EntityType<?>>> FORBIDDEN_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)
|
||||
{
|
||||
|
|
@ -51,7 +55,7 @@ public class ListHandler
|
|||
|
||||
for (TagKey<Block> tag : FORBIDDEN_TILES_TAGS)
|
||||
{
|
||||
if (block.defaultBlockState().m_204336_(tag))
|
||||
if (block.defaultBlockState().is(tag))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +70,7 @@ public class ListHandler
|
|||
|
||||
for (TagKey<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
||||
{
|
||||
if (entity.getType().m_204039_(tag))
|
||||
if (entity.getType().is(tag))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +84,7 @@ public class ListHandler
|
|||
|
||||
for (TagKey<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
||||
{
|
||||
if (entity.getType().m_204039_(tag))
|
||||
if (entity.getType().is(tag))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +98,7 @@ public class ListHandler
|
|||
|
||||
for (TagKey<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
||||
{
|
||||
if (entity.getType().m_204039_(tag))
|
||||
if (entity.getType().is(tag))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +112,7 @@ public class ListHandler
|
|||
|
||||
for (TagKey<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
||||
{
|
||||
if (entity.getType().m_204039_(tag))
|
||||
if (entity.getType().is(tag))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +139,7 @@ public class ListHandler
|
|||
|
||||
for (TagKey<Block> tag : ALLOWED_TILES_TAGS)
|
||||
{
|
||||
if (block.defaultBlockState().m_204336_(tag))
|
||||
if (block.defaultBlockState().is(tag))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -144,6 +148,11 @@ public class ListHandler
|
|||
|
||||
}
|
||||
|
||||
private static void processIMC() {
|
||||
for(Runnable r : IMCMessages)
|
||||
r.run();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void initConfigLists()
|
||||
{
|
||||
|
|
@ -160,9 +169,10 @@ public class ListHandler
|
|||
ALLOWED_TILES.clear();
|
||||
ALLOWED_TILES_TAGS.clear();
|
||||
|
||||
processIMC();
|
||||
|
||||
List<String> forbidden = new ArrayList<>(Blacklist.forbiddenTiles.get());
|
||||
forbidden.add("#carryon:block_blacklist");
|
||||
FORBIDDEN_TILES = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < forbidden.size(); i++)
|
||||
{
|
||||
|
|
@ -172,7 +182,6 @@ public class ListHandler
|
|||
|
||||
List<String> forbiddenEntity = new ArrayList<>(Blacklist.forbiddenEntities.get());
|
||||
forbiddenEntity.add("#carryon:entity_blacklist");
|
||||
FORBIDDEN_ENTITIES = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < forbiddenEntity.size(); i++)
|
||||
{
|
||||
|
|
@ -197,7 +206,6 @@ public class ListHandler
|
|||
|
||||
List<String> allowedEntities = new ArrayList<>(WhiteList.allowedEntities.get());
|
||||
allowedEntities.add("#carryon:entity_whitelist");
|
||||
ALLOWED_ENTITIES = new ArrayList<>();
|
||||
for (int i = 0; i < allowedEntities.size(); i++)
|
||||
{
|
||||
if (!allowedEntities.get(i).startsWith("#"))
|
||||
|
|
@ -221,7 +229,6 @@ public class ListHandler
|
|||
|
||||
List<String> allowedBlocks = new ArrayList<>(WhiteList.allowedBlocks.get());
|
||||
allowedBlocks.add("#carryon:block_whitelist");
|
||||
ALLOWED_TILES = new ArrayList<>();
|
||||
for (int i = 0; i < allowedBlocks.size(); i++)
|
||||
{
|
||||
if (!allowedBlocks.get(i).startsWith("#"))
|
||||
|
|
@ -230,7 +237,6 @@ public class ListHandler
|
|||
|
||||
List<String> forbiddenStacking = new ArrayList<>(Blacklist.forbiddenStacking.get());
|
||||
forbiddenStacking.add("#carryon:stacking_blacklist");
|
||||
FORBIDDEN_STACKING = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < forbiddenStacking.size(); i++)
|
||||
{
|
||||
|
|
@ -255,7 +261,6 @@ public class ListHandler
|
|||
|
||||
List<String> allowedStacking = new ArrayList<>(WhiteList.allowedStacking.get());
|
||||
allowedStacking.add("#carryon:stacking_whitelist");
|
||||
ALLOWED_STACKING = new ArrayList<>();
|
||||
for (int i = 0; i < allowedStacking.size(); i++)
|
||||
{
|
||||
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<EntityType<?>>> entitytags = Registry.ENTITY_TYPE.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.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t));
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
package tschipp.carryon.common.handler;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
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.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
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.helper.CarryonGamestageHelper;
|
||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PickupHandler
|
||||
{
|
||||
|
||||
|
|
@ -92,6 +92,9 @@ public class PickupHandler
|
|||
if (toPickUp instanceof Player)
|
||||
return false;
|
||||
|
||||
if(toPickUp.isRemoved())
|
||||
return false;
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||
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)
|
||||
{
|
||||
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 ItemEntityEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new PositionCommonEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new IMCEvents());
|
||||
}
|
||||
|
||||
public static void regClientEvents()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
//import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class CarryonGamestageHelper
|
||||
{
|
||||
public static boolean hasGamestage(String stage, Player player)
|
||||
{
|
||||
// return GameStageHelper.hasStage(player, stage);
|
||||
return true;
|
||||
return GameStageHelper.hasStage(player, stage);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWKeyCallback;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWKeyCallback;
|
||||
|
||||
public class KeyboardCallbackWrapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWScrollCallback;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWScrollCallback;
|
||||
|
||||
//Thanks to gigaherz for the help!
|
||||
public class ScrollCallbackWrapper
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
package tschipp.carryon.common.item;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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.ModelOverridesHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemCarryonBlock extends Item
|
||||
{
|
||||
|
||||
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()
|
||||
{
|
||||
|
|
@ -57,18 +55,15 @@ public class ItemCarryonBlock extends Item
|
|||
@Override
|
||||
public Component getName(ItemStack stack)
|
||||
{
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
if (hasTileData(stack)) {
|
||||
BlockState state = getBlockState(stack);
|
||||
CompoundTag nbt = getTileData(stack);
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
||||
{
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt)) {
|
||||
Object override = ModelOverridesHandler.getOverrideObject(state, nbt);
|
||||
if (override instanceof ItemStack)
|
||||
return ((ItemStack) override).getHoverName();
|
||||
else
|
||||
{
|
||||
else {
|
||||
BlockState ostate = (BlockState) override;
|
||||
return ostate.getBlock().getName();
|
||||
}
|
||||
|
|
@ -92,26 +87,21 @@ public class ItemCarryonBlock extends Item
|
|||
if (ModList.get().isLoaded("betterplacement") && CarryOnKeybinds.isKeyPressed(player))
|
||||
return InteractionResult.FAIL;
|
||||
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hasTileData(stack)) {
|
||||
try {
|
||||
Vec3 vec = player.getLookAngle();
|
||||
Direction facing2 = Direction.getNearest((float) vec.x, 0f, (float) vec.z);
|
||||
BlockPos pos2 = pos;
|
||||
Block containedblock = getBlock(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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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));
|
||||
|
||||
|
|
@ -142,26 +132,21 @@ public class ItemCarryonBlock extends Item
|
|||
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, level.getBlockState(pos), player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (!event.isCanceled())
|
||||
{
|
||||
if (!event.isCanceled()) {
|
||||
level.setBlockAndUpdate(pos2, actualState);
|
||||
|
||||
// If the blockstate doesn't handle rotation,
|
||||
// try to
|
||||
// change rotation via NBT
|
||||
if (!getTileData(stack).isEmpty())
|
||||
{
|
||||
if (!getTileData(stack).isEmpty()) {
|
||||
CompoundTag tag = getTileData(stack);
|
||||
Set<String> keys = tag.getAllKeys();
|
||||
keytester: for (String key : keys)
|
||||
{
|
||||
for (String facingKey : FACING_KEYS)
|
||||
{
|
||||
if (key.toLowerCase().equals(facingKey))
|
||||
{
|
||||
keytester:
|
||||
for (String key : keys) {
|
||||
for (String facingKey : FACING_KEYS) {
|
||||
if (key.toLowerCase().equals(facingKey)) {
|
||||
byte type = tag.getTagType(key);
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case 8:
|
||||
tag.putString(key, CharMatcher.javaUpperCase().matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
||||
break;
|
||||
|
|
@ -182,11 +167,12 @@ public class ItemCarryonBlock extends Item
|
|||
}
|
||||
|
||||
BlockEntity tile = level.getBlockEntity(pos2);
|
||||
if (tile != null)
|
||||
{
|
||||
if (tile != null) {
|
||||
CompoundTag data = getTileData(stack);
|
||||
updateTileLocation(data, pos2);
|
||||
try {
|
||||
tile.load(data);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
clearTileData(stack);
|
||||
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();
|
||||
|
||||
if (level != null && level.isClientSide)
|
||||
{
|
||||
if (level != null && level.isClientSide) {
|
||||
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(stack));
|
||||
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(stack));
|
||||
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
||||
|
|
@ -232,26 +215,21 @@ public class ItemCarryonBlock extends Item
|
|||
@Override
|
||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
if (hasTileData(stack)) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
if (entity instanceof Player && Settings.slownessInCreative.get() ? false : ((Player) entity).isCreative())
|
||||
return;
|
||||
|
||||
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack), false, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
stack = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasTileData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
if (stack.hasTag()) {
|
||||
CompoundTag tag = stack.getTag();
|
||||
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)
|
||||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
if (stack.hasTag()) {
|
||||
CompoundTag tag = stack.getTag();
|
||||
tag.remove(TILE_DATA_KEY);
|
||||
tag.remove("block");
|
||||
|
|
@ -304,8 +281,7 @@ public class ItemCarryonBlock extends Item
|
|||
|
||||
public static CompoundTag getTileData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
if (stack.hasTag()) {
|
||||
CompoundTag tag = stack.getTag();
|
||||
return tag.getCompound(TILE_DATA_KEY);
|
||||
}
|
||||
|
|
@ -314,8 +290,7 @@ public class ItemCarryonBlock extends Item
|
|||
|
||||
public static Block getBlock(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
if (stack.hasTag()) {
|
||||
CompoundTag tag = stack.getTag();
|
||||
int id = tag.getInt("stateid");
|
||||
return Block.stateById(id).getBlock();
|
||||
|
|
@ -341,8 +316,7 @@ public class ItemCarryonBlock extends Item
|
|||
|
||||
public static BlockState getBlockState(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
if (stack.hasTag()) {
|
||||
CompoundTag tag = stack.getTag();
|
||||
int id = tag.getInt("stateid");
|
||||
return Block.stateById(id);
|
||||
|
|
@ -353,8 +327,7 @@ public class ItemCarryonBlock extends Item
|
|||
public static boolean isLocked(BlockPos pos, Level level)
|
||||
{
|
||||
BlockEntity te = level.getBlockEntity(pos);
|
||||
if (te != null)
|
||||
{
|
||||
if (te != null) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
te.saveWithId();
|
||||
return tag.contains("Lock") ? !tag.getString("Lock").equals("") : false;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package tschipp.carryon.network.client;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
import tschipp.carryon.proxy.ClientProxy;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CarrySlotPacket
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ public class CarrySlotPacket
|
|||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
||||
Level level = CarryOn.proxy.getLevel();
|
||||
Level level = ClientProxy.getLevel();
|
||||
|
||||
if (level != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,17 +3,23 @@ package tschipp.carryon.proxy;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper;
|
||||
import tschipp.carryon.common.helper.ScrollCallbackWrapper;
|
||||
|
||||
public class ClientProxy implements IProxy
|
||||
{
|
||||
|
||||
@Override
|
||||
public void setup(FMLCommonSetupEvent event)
|
||||
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD, value = Dist.CLIENT)
|
||||
public class ClientProxy
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void setup(FMLClientSetupEvent event)
|
||||
{
|
||||
RegistrationHandler.regClientEvents();
|
||||
|
||||
|
|
@ -23,15 +29,12 @@ public class ClientProxy implements IProxy
|
|||
new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer()
|
||||
public static Player getPlayer()
|
||||
{
|
||||
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel()
|
||||
public static Level getLevel()
|
||||
{
|
||||
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