Readded Obfuscate and Gamestage support, fixed several bugs
This commit is contained in:
parent
1ece990eb0
commit
3d4dab6619
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -23,3 +23,5 @@ run
|
|||
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
|
||||
libs/
|
||||
|
|
|
|||
22
build.gradle
22
build.gradle
|
|
@ -92,12 +92,32 @@ repositories {
|
|||
maven {
|
||||
url "https://maven.mcmoddev.com/"
|
||||
}
|
||||
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
|
||||
maven {
|
||||
url "https://www.cursemaven.com"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
//compileOnly fg.deobf("net.darkhax.gamestages:GameStages-1.16.1:3.1.8")
|
||||
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("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}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# 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.15.1
|
||||
minecraft_version=1.16.3
|
||||
mcp_mappings=20200916-1.16.2
|
||||
forge_version=34.1.10
|
||||
version=1.15.2
|
||||
minecraft_version=1.16.5
|
||||
mcp_mappings=20201028-1.16.3
|
||||
forge_version=36.0.22
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package tschipp.carryon;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
|
@ -15,9 +16,9 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
|
|
@ -68,11 +69,11 @@ public class CarryOn
|
|||
CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> version, version::equals, version::equals);
|
||||
|
||||
// CLIENT PACKETS
|
||||
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle);
|
||||
CarryOn.network.registerMessage(1, ScriptReloadPacket.class, ScriptReloadPacket::toBytes, ScriptReloadPacket::new, ScriptReloadPacket::handle);
|
||||
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||
CarryOn.network.registerMessage(1, ScriptReloadPacket.class, ScriptReloadPacket::toBytes, ScriptReloadPacket::new, ScriptReloadPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||
|
||||
// SERVER PACKETS
|
||||
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle);
|
||||
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
||||
|
||||
RegistrationHandler.regCommonEvents();
|
||||
|
||||
|
|
@ -91,13 +92,4 @@ public class CarryOn
|
|||
event.getRegistry().register(RegistrationHandler.itemEntity);
|
||||
event.getRegistry().register(RegistrationHandler.itemTile);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onFingerprintViolation(FMLFingerprintViolationEvent event)
|
||||
{
|
||||
|
||||
LOGGER.error("WARNING! Invalid fingerprint detected! The file " + event.getSource().getName() + " may have been tampered with! If you didn't download the file from https://minecraft.curseforge.com/projects/carry-on or through any kind of mod launcher, immediately delete the file and re-download it from https://minecraft.curseforge.com/projects/carry-on");
|
||||
FINGERPRINT_VIOLATED = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@ import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
|||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent.LoggedInEvent;
|
||||
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
|
|
@ -59,6 +60,7 @@ import tschipp.carryon.CarryOn;
|
|||
import tschipp.carryon.client.helper.CarryRenderHelper;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent;
|
||||
|
|
@ -297,6 +299,13 @@ public class RenderEvents
|
|||
matrix.pop();
|
||||
}
|
||||
}
|
||||
|
||||
// @SubscribeEvent
|
||||
// public void onJoinServer(LoggedInEvent event)
|
||||
// {
|
||||
// ListHandler.initConfigLists();
|
||||
// }
|
||||
|
||||
|
||||
/*
|
||||
* Render blocks and entities in third person
|
||||
|
|
@ -313,7 +322,7 @@ public class RenderEvents
|
|||
int light = 0;
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableDepthTest();
|
||||
|
|
|
|||
|
|
@ -15,15 +15,12 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
|
||||
public class CommandCarryOn
|
||||
{
|
||||
|
|
@ -43,7 +40,7 @@ public class CommandCarryOn
|
|||
return handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target"));
|
||||
})))
|
||||
|
||||
;
|
||||
;
|
||||
|
||||
dispatcher.register(builder);
|
||||
|
||||
|
|
@ -81,7 +78,8 @@ public class CommandCarryOn
|
|||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(main)));
|
||||
|
||||
return 1;
|
||||
} else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
||||
}
|
||||
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
||||
{
|
||||
source.sendFeedback(new StringTextComponent("Entity: " + ItemCarryonEntity.getEntity(main, player.world)), true);
|
||||
source.sendFeedback(new StringTextComponent("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true);
|
||||
|
|
@ -99,7 +97,8 @@ public class CommandCarryOn
|
|||
}
|
||||
}
|
||||
|
||||
} catch (CommandSyntaxException e)
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -111,32 +110,20 @@ public class CommandCarryOn
|
|||
{
|
||||
for (ServerPlayerEntity player : players)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (source.assertIsEntity() != null)
|
||||
{
|
||||
int cleared = 0;
|
||||
cleared += player.inventory.func_234564_a_(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, null); //TODO
|
||||
cleared += player.inventory.func_234564_a_(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, null);
|
||||
int cleared = 0;
|
||||
cleared += player.inventory.func_234564_a_(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, player.container.func_234641_j_()); // TODO
|
||||
cleared += player.inventory.func_234564_a_(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, player.container.func_234641_j_());
|
||||
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(9, player.getEntityId()));
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(9, player.getEntityId()));
|
||||
|
||||
if (cleared != 1)
|
||||
source.sendFeedback(new StringTextComponent("Cleared " + cleared + " Items!"), true);
|
||||
else
|
||||
source.sendFeedback(new StringTextComponent("Cleared " + cleared + " Item!"), true);
|
||||
if (cleared != 1)
|
||||
source.sendFeedback(new StringTextComponent("Cleared " + cleared + " Items!"), true);
|
||||
else
|
||||
source.sendFeedback(new StringTextComponent("Cleared " + cleared + " Item!"), true);
|
||||
|
||||
return 1;
|
||||
} else
|
||||
throw EntityArgument.ONLY_PLAYERS_ALLOWED.create();
|
||||
|
||||
} catch (CommandSyntaxException e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class Configs {
|
|||
{
|
||||
if(event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
ListHandler.initLists();
|
||||
ListHandler.initConfigLists();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ public class Configs {
|
|||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
s.comment("Whitelist");
|
||||
s.comment("Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
||||
|
||||
allowedEntities = s
|
||||
.comment("Entities that CAN be picked up (useWhitelistEntities must be true)")
|
||||
|
|
@ -261,12 +261,15 @@ public class Configs {
|
|||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
s.comment("Blacklist");
|
||||
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(new String[]
|
||||
{
|
||||
"#forge:immovable",
|
||||
"#forge:relocation_not_supported",
|
||||
"#mekanism:cardboard_blacklist",
|
||||
"minecraft:end_portal",
|
||||
"minecraft:end_gateway",
|
||||
"minecraft:tall_grass",
|
||||
|
|
@ -350,7 +353,10 @@ public class Configs {
|
|||
"wearablebackpacks:*",
|
||||
"rftools:screen",
|
||||
"rftools:creative_screen",
|
||||
"create:*"
|
||||
"create:*",
|
||||
"magic_doorknob:*",
|
||||
"iceandfire:*",
|
||||
"ftbquests:*"
|
||||
|
||||
|
||||
}), (obj) -> obj instanceof String ? true : false);
|
||||
|
|
@ -375,7 +381,9 @@ public class Configs {
|
|||
"animania:wagon",
|
||||
"mynko:*",
|
||||
"pixelmon:*",
|
||||
"mocreatures:*"
|
||||
"mocreatures:*",
|
||||
"quark:totem",
|
||||
"vehicle:*"
|
||||
}), (obj) -> obj instanceof String ? true : false);
|
||||
|
||||
forbiddenStacking = s
|
||||
|
|
@ -394,7 +402,7 @@ public class Configs {
|
|||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
c.comment("Model Overrides");
|
||||
c.comment("Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config");
|
||||
|
||||
|
||||
modelOverrides = c
|
||||
|
|
@ -409,41 +417,6 @@ public class Configs {
|
|||
"minecraft:flower_pot->(block)minecraft:flower_pot",
|
||||
"minecraft:sugar_cane->(block)minecraft:sugar_cane",
|
||||
"minecraft:redstone_wire->(item)minecraft:redstone",
|
||||
"quark:custom_chest{type:\"spruce\"}->quark:custom_chest;0",
|
||||
"quark:custom_chest{type:\"birch\"}->quark:custom_chest;1",
|
||||
"quark:custom_chest{type:\"jungle\"}->quark:custom_chest;2",
|
||||
"quark:custom_chest{type:\"acacia\"}->quark:custom_chest;3",
|
||||
"quark:custom_chest{type:\"dark_oak\"}->quark:custom_chest;4",
|
||||
"quark:custom_chest_trap{type:\"spruce\"}->quark:custom_chest_trap;0",
|
||||
"quark:custom_chest_trap{type:\"birch\"}->quark:custom_chest_trap;1",
|
||||
"quark:custom_chest_trap{type:\"jungle\"}->quark:custom_chest_trap;2",
|
||||
"quark:custom_chest_trap{type:\"acacia\"}->quark:custom_chest_trap;3",
|
||||
"quark:custom_chest_trap{type:\"dark_oak\"}->quark:custom_chest_trap;4",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"spruce\"}->storagedrawers:basicdrawers;0{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"birch\"}->storagedrawers:basicdrawers;0{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"jungle\"}->storagedrawers:basicdrawers;0{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"acacia\"}->storagedrawers:basicdrawers;0{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;0{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"spruce\"}->storagedrawers:basicdrawers;1{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"birch\"}->storagedrawers:basicdrawers;1{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"jungle\"}->storagedrawers:basicdrawers;1{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"acacia\"}->storagedrawers:basicdrawers;1{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;1{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"spruce\"}->storagedrawers:basicdrawers;2{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"birch\"}->storagedrawers:basicdrawers;2{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"jungle\"}->storagedrawers:basicdrawers;2{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"acacia\"}->storagedrawers:basicdrawers;2{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;2{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"spruce\"}->storagedrawers:basicdrawers;3{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"birch\"}->storagedrawers:basicdrawers;3{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"jungle\"}->storagedrawers:basicdrawers;3{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"acacia\"}->storagedrawers:basicdrawers;3{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;3{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"spruce\"}->storagedrawers:basicdrawers;4{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"birch\"}->storagedrawers:basicdrawers;4{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"jungle\"}->storagedrawers:basicdrawers;4{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"acacia\"}->storagedrawers:basicdrawers;4{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;4{material:\"dark_oak\"}",
|
||||
"animania:block_nest->(block)animania:block_nest",
|
||||
"animania:cheese_mold;0->(block)animania:cheese_mold;0",
|
||||
"animania:cheese_mold;1->(block)animania:cheese_mold;1",
|
||||
|
|
@ -471,7 +444,7 @@ public class Configs {
|
|||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
s.comment("Custom Pickup Conditions");
|
||||
s.comment("Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config");
|
||||
|
||||
|
||||
customPickupConditionsBlocks = s
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class ItemEntityEvents
|
|||
if (entity instanceof AnimalEntity)
|
||||
((AnimalEntity) entity).clearLeashed(true, true);
|
||||
|
||||
if (PickupHandler.canPlayerPickUpEntity(player, entity))
|
||||
if (PickupHandler.canPlayerPickUpEntity((ServerPlayerEntity) player, entity))
|
||||
{
|
||||
if (ItemCarryonEntity.storeEntityData(entity, world, stack))
|
||||
{
|
||||
|
|
@ -132,6 +132,7 @@ public class ItemEntityEvents
|
|||
if (entity instanceof LivingEntity)
|
||||
((LivingEntity) entity).setHealth(0);
|
||||
|
||||
entity.removePassengers();
|
||||
entity.setPosition(entity.getPosX(), 0, entity.getPosZ());
|
||||
entity.remove();
|
||||
player.setHeldItem(Hand.MAIN_HAND, stack);
|
||||
|
|
@ -148,7 +149,7 @@ public class ItemEntityEvents
|
|||
if (entity.hurtResistantTime == 0 && entityHeld instanceof LivingEntity)
|
||||
{
|
||||
|
||||
if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && !entityHeld.isAlive() && !entity.isAlive())
|
||||
if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && entity.isAlive())
|
||||
{
|
||||
|
||||
double sizeHeldEntity = entityHeld.getHeight() * entityHeld.getWidth();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import net.minecraft.world.GameRules;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.TagsUpdatedEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
|
@ -55,6 +56,7 @@ import tschipp.carryon.common.config.Configs.Settings;
|
|||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.PickupHandler.PickUpBlockEvent;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
|
|
@ -143,7 +145,7 @@ public class ItemEvents
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerLogin(PlayerLoggedInEvent event)
|
||||
{
|
||||
|
|
@ -191,8 +193,12 @@ public class ItemEvents
|
|||
public void serverLoad(FMLServerStartingEvent event)
|
||||
{
|
||||
CustomPickupOverrideHandler.initPickupOverrides();
|
||||
ListHandler.initLists();
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void reloadTags(TagsUpdatedEvent event)
|
||||
{
|
||||
ListHandler.initConfigLists();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -286,10 +292,13 @@ public class ItemEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
|
||||
if(event.isCanceled())
|
||||
return;
|
||||
|
||||
if (!player.world.isRemote)
|
||||
{
|
||||
|
|
@ -306,9 +315,11 @@ public class ItemEvents
|
|||
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
||||
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (PickupHandler.canPlayerPickUpBlock(player, te, world, pos))
|
||||
if (PickupHandler.canPlayerPickUpBlock((ServerPlayerEntity) player, te, world, pos))
|
||||
{
|
||||
player.closeScreen();
|
||||
world.playEvent(1010, pos, 0);
|
||||
|
||||
|
||||
if (ItemCarryonBlock.storeTileData(te, world, pos, state, stack))
|
||||
{
|
||||
|
|
@ -517,7 +528,7 @@ public class ItemEvents
|
|||
{
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
ListHandler.initLists();
|
||||
ListHandler.initConfigLists();
|
||||
|
||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
||||
|
|
|
|||
|
|
@ -2,9 +2,18 @@ package tschipp.carryon.common.handler;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.arguments.BlockStateParser;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import tschipp.carryon.common.config.Configs.CustomPickupConditions;
|
||||
|
|
@ -74,28 +83,65 @@ public class CustomPickupOverrideHandler
|
|||
}
|
||||
}
|
||||
|
||||
private static final Function<Entry<Property<?>, Comparable<?>>, String> func = new Function<Entry<Property<?>, Comparable<?>>, String>() {
|
||||
public String apply(@Nullable Entry<Property<?>, Comparable<?>> p_apply_1_)
|
||||
{
|
||||
if (p_apply_1_ == null)
|
||||
{
|
||||
return "<NULL>";
|
||||
}
|
||||
else
|
||||
{
|
||||
Property<?> property = p_apply_1_.getKey();
|
||||
return property.getName() + "=" + this.func_235905_a_(property, p_apply_1_.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Comparable<T>> String func_235905_a_(Property<T> p_235905_1_, Comparable<?> comp)
|
||||
{
|
||||
return p_235905_1_.getName((T) comp);
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean hasSpecialPickupConditions(BlockState state)
|
||||
{
|
||||
if (!ModList.get().isLoaded("gamestages"))
|
||||
return false;
|
||||
|
||||
String block = state.getBlock().getRegistryName().toString();
|
||||
for(String cond : PICKUP_CONDITIONS.keySet())
|
||||
{
|
||||
BlockStateParser parser = new BlockStateParser(new StringReader(cond), false);
|
||||
try
|
||||
{
|
||||
parser.parse(false);
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
}
|
||||
if(parser.getState() == state)
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean absolute = PICKUP_CONDITIONS.containsKey(block);
|
||||
|
||||
return absolute;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getPickupCondition(BlockState state)
|
||||
{
|
||||
String block = state.getBlock().getRegistryName().toString();
|
||||
|
||||
String absolute = PICKUP_CONDITIONS.get(block);
|
||||
|
||||
if (absolute != null)
|
||||
return absolute;
|
||||
else
|
||||
return null;
|
||||
for(String cond : PICKUP_CONDITIONS.keySet())
|
||||
{
|
||||
BlockStateParser parser = new BlockStateParser(new StringReader(cond), false);
|
||||
try
|
||||
{
|
||||
parser.parse(false);
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
}
|
||||
if(parser.getState() == state)
|
||||
return PICKUP_CONDITIONS.get(cond);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasSpecialPickupConditions(Entity entity)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.tags.ITagCollection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import tschipp.carryon.common.config.Configs.Blacklist;
|
||||
|
|
@ -12,12 +17,19 @@ import tschipp.carryon.common.config.Configs.WhiteList;
|
|||
|
||||
public class ListHandler
|
||||
{
|
||||
public static List<String> FORBIDDEN_TILES;
|
||||
public static List<String> FORBIDDEN_ENTITIES;
|
||||
public static List<String> ALLOWED_ENTITIES;
|
||||
public static List<String> ALLOWED_TILES;
|
||||
public static List<String> FORBIDDEN_STACKING;
|
||||
public static List<String> ALLOWED_STACKING;
|
||||
public static List<String> FORBIDDEN_TILES = new ArrayList<>();
|
||||
public static List<String> FORBIDDEN_ENTITIES = new ArrayList<>();
|
||||
public static List<String> ALLOWED_ENTITIES = new ArrayList<>();
|
||||
public static List<String> ALLOWED_TILES = new ArrayList<>();
|
||||
public static List<String> FORBIDDEN_STACKING = new ArrayList<>();
|
||||
public static List<String> ALLOWED_STACKING = new ArrayList<>();
|
||||
|
||||
public static List<ITag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> ALLOWED_ENTITIES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
||||
|
||||
public static boolean isForbidden(Block block)
|
||||
{
|
||||
|
|
@ -36,6 +48,12 @@ public class ListHandler
|
|||
contains = true;
|
||||
}
|
||||
}
|
||||
|
||||
for(ITag<Block> tag : FORBIDDEN_TILES_TAGS)
|
||||
{
|
||||
if(tag.contains(block))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
|
@ -45,6 +63,13 @@ public class ListHandler
|
|||
{
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
||||
|
||||
for(ITag<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
||||
{
|
||||
if(tag.contains(entity.getType()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +77,13 @@ public class ListHandler
|
|||
{
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = ALLOWED_ENTITIES.contains(name);
|
||||
|
||||
for(ITag<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
||||
{
|
||||
if(tag.contains(entity.getType()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +91,13 @@ public class ListHandler
|
|||
{
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = FORBIDDEN_STACKING.contains(name);
|
||||
|
||||
for(ITag<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
||||
{
|
||||
if(tag.contains(entity.getType()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +105,13 @@ public class ListHandler
|
|||
{
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = ALLOWED_STACKING.contains(name);
|
||||
|
||||
for(ITag<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
||||
{
|
||||
if(tag.contains(entity.getType()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
|
|
@ -86,123 +132,227 @@ public class ListHandler
|
|||
contains = true;
|
||||
}
|
||||
}
|
||||
|
||||
for(ITag<Block> tag : ALLOWED_TILES_TAGS)
|
||||
{
|
||||
if(tag.contains(block))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void initLists()
|
||||
public static void initConfigLists()
|
||||
{
|
||||
List<String> forbidden = (List<String>) Blacklist.forbiddenTiles.get();
|
||||
FORBIDDEN_ENTITIES.clear();
|
||||
FORBIDDEN_ENTITIES_TAGS.clear();
|
||||
FORBIDDEN_STACKING.clear();
|
||||
FORBIDDEN_STACKING_TAGS.clear();
|
||||
FORBIDDEN_TILES.clear();
|
||||
FORBIDDEN_TILES_TAGS.clear();
|
||||
ALLOWED_ENTITIES.clear();
|
||||
ALLOWED_ENTITIES_TAGS.clear();
|
||||
ALLOWED_STACKING.clear();
|
||||
ALLOWED_STACKING_TAGS.clear();
|
||||
ALLOWED_TILES.clear();
|
||||
ALLOWED_TILES_TAGS.clear();
|
||||
|
||||
List<String> forbidden = new ArrayList<>(Blacklist.forbiddenTiles.get());
|
||||
forbidden.add("#carryon:block_blacklist");
|
||||
FORBIDDEN_TILES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbidden.size(); i++)
|
||||
{
|
||||
FORBIDDEN_TILES.add(forbidden.get(i));
|
||||
if (!forbidden.get(i).startsWith("#"))
|
||||
FORBIDDEN_TILES.add(forbidden.get(i));
|
||||
}
|
||||
|
||||
List<String> forbiddenEntity = (List<String>) Blacklist.forbiddenEntities.get();
|
||||
List<String> forbiddenEntity = new ArrayList<>(Blacklist.forbiddenEntities.get());
|
||||
forbiddenEntity.add("#carryon:entity_blacklist");
|
||||
FORBIDDEN_ENTITIES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbiddenEntity.size(); i++)
|
||||
{
|
||||
if (forbiddenEntity.get(i).contains("*"))
|
||||
if (!forbiddenEntity.get(i).startsWith("#"))
|
||||
{
|
||||
String[] filter = forbiddenEntity.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
if (forbiddenEntity.get(i).contains("*"))
|
||||
{
|
||||
if (containsAll(key.toString(), filter))
|
||||
String[] filter = forbiddenEntity.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
FORBIDDEN_ENTITIES.add(key.toString());
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
FORBIDDEN_ENTITIES.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
FORBIDDEN_ENTITIES.add(forbiddenEntity.get(i));
|
||||
}
|
||||
FORBIDDEN_ENTITIES.add(forbiddenEntity.get(i));
|
||||
}
|
||||
|
||||
List<String> allowedEntities = (List<String>) WhiteList.allowedEntities.get();
|
||||
List<String> allowedEntities = new ArrayList<>(WhiteList.allowedEntities.get());
|
||||
allowedEntities.add("#carryon:entity_whitelist");
|
||||
ALLOWED_ENTITIES = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedEntities.size(); i++)
|
||||
{
|
||||
if (allowedEntities.get(i).contains("*"))
|
||||
if (!allowedEntities.get(i).startsWith("#"))
|
||||
{
|
||||
String[] filter = allowedEntities.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
if (allowedEntities.get(i).contains("*"))
|
||||
{
|
||||
if (containsAll(key.toString(), filter))
|
||||
String[] filter = allowedEntities.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
ALLOWED_ENTITIES.add(key.toString());
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
ALLOWED_ENTITIES.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
ALLOWED_ENTITIES.add(allowedEntities.get(i));
|
||||
}
|
||||
ALLOWED_ENTITIES.add(allowedEntities.get(i));
|
||||
}
|
||||
|
||||
List<String> allowedBlocks = (List<String>) WhiteList.allowedBlocks.get();
|
||||
List<String> allowedBlocks = new ArrayList<>(WhiteList.allowedBlocks.get());
|
||||
allowedBlocks.add("#carryon:block_whitelist");
|
||||
ALLOWED_TILES = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedBlocks.size(); i++)
|
||||
{
|
||||
ALLOWED_TILES.add(allowedBlocks.get(i));
|
||||
if (!allowedBlocks.get(i).startsWith("#"))
|
||||
ALLOWED_TILES.add(allowedBlocks.get(i));
|
||||
}
|
||||
|
||||
List<String> forbiddenStacking = (List<String>) Blacklist.forbiddenStacking.get();
|
||||
List<String> forbiddenStacking = new ArrayList<>(Blacklist.forbiddenStacking.get());
|
||||
forbiddenStacking.add("#carryon:stacking_blacklist");
|
||||
FORBIDDEN_STACKING = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbiddenStacking.size(); i++)
|
||||
{
|
||||
if (forbiddenStacking.get(i).contains("*"))
|
||||
if (!forbiddenStacking.get(i).startsWith("#"))
|
||||
{
|
||||
String[] filter = forbiddenStacking.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
if (forbiddenStacking.get(i).contains("*"))
|
||||
{
|
||||
if (containsAll(key.toString(), filter))
|
||||
String[] filter = forbiddenStacking.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
FORBIDDEN_STACKING.add(key.toString());
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
FORBIDDEN_STACKING.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
FORBIDDEN_STACKING.add(forbiddenStacking.get(i));
|
||||
}
|
||||
FORBIDDEN_STACKING.add(forbiddenStacking.get(i));
|
||||
}
|
||||
|
||||
List<String> allowedStacking = (List<String>) WhiteList.allowedStacking.get();
|
||||
List<String> allowedStacking = new ArrayList<>(WhiteList.allowedStacking.get());
|
||||
allowedStacking.add("#carryon:stacking_whitelist");
|
||||
ALLOWED_STACKING = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedStacking.size(); i++)
|
||||
{
|
||||
if (allowedStacking.get(i).contains("*"))
|
||||
if (!allowedStacking.get(i).startsWith("#"))
|
||||
{
|
||||
String[] filter = allowedStacking.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
if (allowedStacking.get(i).contains("*"))
|
||||
{
|
||||
if (containsAll(key.toString(), filter))
|
||||
String[] filter = allowedStacking.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
ALLOWED_STACKING.add(key.toString());
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
ALLOWED_STACKING.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
ALLOWED_STACKING.add(allowedStacking.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
ITagCollection<Block> blocktags = BlockTags.getCollection();
|
||||
ITagCollection<EntityType<?>> entitytags = EntityTypeTags.getCollection();
|
||||
|
||||
System.out.println(blocktags.getRegisteredTags());
|
||||
|
||||
for (String s : forbidden)
|
||||
{
|
||||
if (s.startsWith("#"))
|
||||
{
|
||||
String sub = s.substring(1, s.length());
|
||||
ITag<Block> tag = blocktags.get(new ResourceLocation(sub));
|
||||
if (tag != null)
|
||||
FORBIDDEN_TILES_TAGS.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : allowedBlocks)
|
||||
{
|
||||
if (s.startsWith("#"))
|
||||
{
|
||||
ITag<Block> tag = blocktags.get(new ResourceLocation(s.substring(1, s.length())));
|
||||
if (tag != null)
|
||||
ALLOWED_TILES_TAGS.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : forbiddenEntity)
|
||||
{
|
||||
if (s.startsWith("#"))
|
||||
{
|
||||
ITag<EntityType<?>> tag = entitytags.get(new ResourceLocation(s.substring(1, s.length())));
|
||||
if (tag != null)
|
||||
FORBIDDEN_ENTITIES_TAGS.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : allowedEntities)
|
||||
{
|
||||
if (s.startsWith("#"))
|
||||
{
|
||||
ITag<EntityType<?>> tag = entitytags.get(new ResourceLocation(s.substring(1, s.length())));
|
||||
if (tag != null)
|
||||
ALLOWED_ENTITIES_TAGS.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : forbiddenStacking)
|
||||
{
|
||||
if (s.startsWith("#"))
|
||||
{
|
||||
ITag<EntityType<?>> tag = entitytags.get(new ResourceLocation(s.substring(1, s.length())));
|
||||
if (tag != null)
|
||||
FORBIDDEN_STACKING_TAGS.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : allowedStacking)
|
||||
{
|
||||
if (s.startsWith("#"))
|
||||
{
|
||||
ITag<EntityType<?>> tag = entitytags.get(new ResourceLocation(s.substring(1, s.length())));
|
||||
if (tag != null)
|
||||
ALLOWED_STACKING_TAGS.add(tag);
|
||||
}
|
||||
ALLOWED_STACKING.add(allowedStacking.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean containsAll(String str, String... strings)
|
||||
{
|
||||
boolean containsAll = true;
|
||||
|
||||
for(String s : strings)
|
||||
|
||||
for (String s : strings)
|
||||
{
|
||||
if(!str.contains(s))
|
||||
if (!str.contains(s))
|
||||
containsAll = false;
|
||||
}
|
||||
|
||||
|
||||
return containsAll;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import net.minecraft.nbt.CompoundNBT;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
|
|
@ -28,8 +29,11 @@ import tschipp.carryon.common.scripting.ScriptChecker;
|
|||
public class PickupHandler
|
||||
{
|
||||
|
||||
public static boolean canPlayerPickUpBlock(PlayerEntity player, @Nullable TileEntity tile, World world, BlockPos pos)
|
||||
public static boolean canPlayerPickUpBlock(ServerPlayerEntity player, @Nullable TileEntity tile, World world, BlockPos pos)
|
||||
{
|
||||
if(player.interactionManager.getGameType() == GameType.SPECTATOR || player.interactionManager.getGameType() == GameType.ADVENTURE)
|
||||
return false;
|
||||
|
||||
|
||||
BlockState state = world.getBlockState(pos);
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
|
@ -75,7 +79,7 @@ public class PickupHandler
|
|||
}
|
||||
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
||||
{
|
||||
return handleProtections((ServerPlayerEntity) player, world, pos, state);
|
||||
return handleProtections(player, world, pos, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -86,8 +90,11 @@ public class PickupHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean canPlayerPickUpEntity(PlayerEntity player, Entity toPickUp)
|
||||
public static boolean canPlayerPickUpEntity(ServerPlayerEntity player, Entity toPickUp)
|
||||
{
|
||||
if(player.interactionManager.getGameType() == GameType.SPECTATOR || player.interactionManager.getGameType() == GameType.ADVENTURE)
|
||||
return false;
|
||||
|
||||
BlockPos pos = toPickUp.getPosition();
|
||||
|
||||
if (toPickUp instanceof PlayerEntity)
|
||||
|
|
@ -96,7 +103,7 @@ public class PickupHandler
|
|||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||
if (override != null)
|
||||
{
|
||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((ServerPlayerEntity) player, toPickUp);
|
||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections(player, toPickUp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -177,11 +184,27 @@ public class PickupHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
public static class PickUpBlockEvent extends BlockEvent.BreakEvent
|
||||
{
|
||||
public PickUpBlockEvent(World world, BlockPos pos, BlockState state, PlayerEntity player)
|
||||
{
|
||||
super(world, pos, state, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PickUpEntityEvent extends AttackEntityEvent
|
||||
{
|
||||
public PickUpEntityEvent(PlayerEntity player, Entity target)
|
||||
{
|
||||
super(player, target);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean handleProtections(ServerPlayerEntity player, World world, BlockPos pos, BlockState state)
|
||||
{
|
||||
boolean breakable = true;
|
||||
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player);
|
||||
PickUpBlockEvent event = new PickUpBlockEvent(world, pos, state, player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.isCanceled())
|
||||
|
|
@ -194,7 +217,7 @@ public class PickupHandler
|
|||
{
|
||||
boolean canPickup = true;
|
||||
|
||||
AttackEntityEvent event = new AttackEntityEvent(player, entity);
|
||||
PickUpEntityEvent event = new PickUpEntityEvent(player, entity);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.isCanceled())
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class RegistrationHandler
|
|||
{
|
||||
ModelOverridesHandler.initOverrides();
|
||||
CustomPickupOverrideHandler.initPickupOverrides();
|
||||
ListHandler.initLists();
|
||||
// ListHandler.initConfigLists();
|
||||
}
|
||||
|
||||
public static void regCaps()
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
public class CarryonGamestageHelper
|
||||
{
|
||||
public static boolean hasGamestage(String stage, PlayerEntity player)
|
||||
{
|
||||
// return GameStageHelper.hasStage(player, stage);
|
||||
return true;
|
||||
return GameStageHelper.hasStage(player, stage);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,9 +119,10 @@ public class ItemCarryonBlock extends Item
|
|||
{
|
||||
|
||||
BlockState placementState = containedblock.getStateForPlacement(new BlockItemUseContext(context));
|
||||
|
||||
BlockState actualState = placementState == null ? containedstate : placementState;
|
||||
|
||||
BlockState actualState = placementState;
|
||||
|
||||
//Attempted fix for #287
|
||||
// for (IProperty<?> prop : placementState.getValues().keySet())
|
||||
// {
|
||||
// if (prop instanceof DirectionProperty)
|
||||
|
|
@ -184,8 +185,9 @@ public class ItemCarryonBlock extends Item
|
|||
TileEntity tile = world.getTileEntity(pos2);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.deserializeNBT(getTileData(stack));
|
||||
tile.setPos(pos2);
|
||||
CompoundNBT data = getTileData(stack);
|
||||
updateTileLocation(data, pos2);
|
||||
tile.read(actualState, data);
|
||||
}
|
||||
clearTileData(stack);
|
||||
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
||||
|
|
@ -264,15 +266,15 @@ public class ItemCarryonBlock extends Item
|
|||
if (stack.isEmpty())
|
||||
return false;
|
||||
|
||||
CompoundNBT chest = new CompoundNBT();
|
||||
CompoundNBT tileTag = new CompoundNBT();
|
||||
if (tile != null)
|
||||
chest = tile.write(chest);
|
||||
tileTag = tile.write(tileTag);
|
||||
|
||||
CompoundNBT tag = stack.hasTag() ? stack.getTag() : new CompoundNBT();
|
||||
if (tag.contains(TILE_DATA_KEY))
|
||||
return false;
|
||||
|
||||
tag.put(TILE_DATA_KEY, chest);
|
||||
tag.put(TILE_DATA_KEY, tileTag);
|
||||
|
||||
// ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state,
|
||||
// itemRand, 0), 1, state.getBlock().damageDropped(state));
|
||||
|
|
@ -284,6 +286,13 @@ public class ItemCarryonBlock extends Item
|
|||
stack.setTag(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void updateTileLocation(CompoundNBT tag, BlockPos pos)
|
||||
{
|
||||
tag.putInt("x", pos.getX());
|
||||
tag.putInt("y", pos.getY());
|
||||
tag.putInt("z", pos.getZ());
|
||||
}
|
||||
|
||||
public static void clearTileData(ItemStack stack)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,79 +1,101 @@
|
|||
package tschipp.carryon.compat.obfuscate;
|
||||
|
||||
import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
||||
|
||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.entity.Pose;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class ObfuscateEvents
|
||||
{
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void preModelPlayerEvent(ModelPlayerEvent.SetupAngles.Post event)
|
||||
// {
|
||||
// if(!CarryOnConfig.settings.renderArms.get())
|
||||
// return;
|
||||
//
|
||||
// PlayerEntity player = event.getPlayerEntity();
|
||||
//
|
||||
// ModelPlayer model = event.getModelPlayer();
|
||||
// ItemStack stack = player.getHeldItemMainhand();
|
||||
// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
// {
|
||||
//
|
||||
// float rotation = 0;
|
||||
//
|
||||
// CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
// if (overrider != null)
|
||||
// {
|
||||
// double[] rotLeft = null;
|
||||
// double[] rotRight = null;
|
||||
// if (overrider.getRenderRotationLeftArm() != null)
|
||||
// rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
// if (overrider.getRenderRotationRightArm() != null)
|
||||
// rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
//
|
||||
// boolean renderRight = overrider.isRenderRightArm();
|
||||
// boolean renderLeft = overrider.isRenderLeftArm();
|
||||
//
|
||||
// if (renderLeft && rotLeft != null)
|
||||
// {
|
||||
// renderArmPre(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
// renderArmPre(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
// }
|
||||
// else if (renderLeft)
|
||||
// {
|
||||
// renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// }
|
||||
//
|
||||
// if (renderRight && rotRight != null)
|
||||
// {
|
||||
// renderArmPre(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
// renderArmPre(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
// }
|
||||
// else if (renderRight)
|
||||
// {
|
||||
// renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
||||
// {
|
||||
// arm.rotateAngleX = (float) -x;
|
||||
// arm.rotateAngleY = (float) -Math.toRadians(rotation);
|
||||
// arm.rotateAngleZ = (float) z;
|
||||
// }
|
||||
//
|
||||
|
||||
@SubscribeEvent
|
||||
public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
||||
{
|
||||
if(!Settings.renderArms.get())
|
||||
return;
|
||||
|
||||
PlayerEntity player = event.getPlayer();
|
||||
|
||||
Pose pose = player.getPose();
|
||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
return;
|
||||
|
||||
PlayerModel<?> model = event.getModelPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
{
|
||||
|
||||
float rotation = 0;
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
float[] rotLeft = null;
|
||||
float[] rotRight = null;
|
||||
if (overrider.getRenderRotationLeftArm() != null)
|
||||
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
if (overrider.getRenderRotationRightArm() != null)
|
||||
rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
|
||||
boolean renderRight = overrider.isRenderRightArm();
|
||||
boolean renderLeft = overrider.isRenderLeftArm();
|
||||
|
||||
if (renderLeft && rotLeft != null)
|
||||
{
|
||||
renderArmPre(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
renderArmPre(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
}
|
||||
else if (renderLeft)
|
||||
{
|
||||
renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
if (renderRight && rotRight != null)
|
||||
{
|
||||
renderArmPre(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
renderArmPre(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
}
|
||||
else if (renderRight)
|
||||
{
|
||||
renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
||||
{
|
||||
arm.rotateAngleX = (float) -x;
|
||||
arm.rotateAngleY = (float) -Math.toRadians(rotation);
|
||||
arm.rotateAngleZ = (float) z;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class ClientProxy implements IProxy {
|
|||
@Override
|
||||
public PlayerEntity getPlayer()
|
||||
{
|
||||
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user