Update to 1.14.2

This commit is contained in:
Marcel Konrad
2019-06-18 17:37:55 +02:00
parent ae1bc97906
commit e5e6226fbf
90 changed files with 1310 additions and 1447 deletions

View File

@@ -1,7 +1,5 @@
package exopandora.worldhandler.helper;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.impl.BuilderDifficulty;
@@ -17,13 +15,15 @@ import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.NoteBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraftforge.api.distmarker.Dist;
@@ -130,23 +130,23 @@ public class ActionHelper
{
try
{
action.run();
if(action != null)
{
action.run();
}
}
catch(Exception e)
{
if(!Minecraft.getInstance().isGameFocused())
{
Minecraft.getInstance().displayGuiScreen(null);
Minecraft.getInstance().mouseHelper.grabMouse();
}
Minecraft.getInstance().displayGuiScreen(null);
Minecraft.getInstance().mouseHelper.grabMouse();
TextComponentString name = new TextComponentString(Main.NAME);
StringTextComponent name = new StringTextComponent(Main.NAME);
name.setStyle(new Style().setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, Main.URL)));
TextComponentTranslation message = new TextComponentTranslation("worldhandler.error.gui", name);
TranslationTextComponent message = new TranslationTextComponent("worldhandler.error.gui", name);
message.setStyle(new Style().setColor(net.minecraft.util.text.TextFormatting.RED));
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
Minecraft.getInstance().field_71456_v.addChatMessage(ChatType.SYSTEM, message);
WorldHandler.LOGGER.throwing(e);
}
}
@@ -155,18 +155,18 @@ public class ActionHelper
{
if(!CommandHelper.canPlayerIssueCommand() && Config.getSettings().permissionQuery())
{
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
Minecraft.getInstance().field_71456_v.addChatMessage(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getInstance().field_71456_v.addChatMessage(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
}
else
{
ActionHelper.tryRun(() ->
{
if(BlockHelper.isFocusedBlockEqualTo(Blocks.SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
if(BlockHelper.getFocusedBlock() instanceof AbstractSignBlock)
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.SIGN_EDITOR));
}
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTE_BLOCK))
else if(BlockHelper.getFocusedBlock() instanceof NoteBlock)
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.NOTE_EDITOR));
}

View File

@@ -18,49 +18,52 @@ import exopandora.worldhandler.builder.types.CoordinateDouble;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.config.Config;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityType;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.play.client.CPacketUpdateCommandBlock;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.DoubleNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.network.play.client.CUpdateCommandBlockPacket;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.EnumFacing;
import net.minecraft.tileentity.CommandBlockTileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BlockHelper
{
private static BlockPos POS_1 = BlockPos.ORIGIN;
private static BlockPos POS_2 = BlockPos.ORIGIN;
private static BlockPos POS_1 = BlockPos.ZERO;
private static BlockPos POS_2 = BlockPos.ZERO;
private static final List<Consumer<BlockPos>> POS_1_OBSERVERS = new ArrayList<Consumer<BlockPos>>();
private static final List<Consumer<BlockPos>> POS_2_OBSERVERS = new ArrayList<Consumer<BlockPos>>();
private static final Block[] BLACKLIST = new Block[] {Blocks.AIR, Blocks.WATER, Blocks.LAVA};
public static BlockPos getFocusedBlockPos()
{
RayTraceResult rayTrace = Minecraft.getInstance().objectMouseOver;
RayTraceResult result = Minecraft.getInstance().objectMouseOver;
if(rayTrace != null && rayTrace.type.equals(RayTraceResult.Type.BLOCK))
if(result != null && result.getType().equals(Type.BLOCK))
{
BlockPos position = rayTrace.getBlockPos();
BlockRayTraceResult blockResult = (BlockRayTraceResult) result;
if(!ArrayUtils.contains(BLACKLIST, Minecraft.getInstance().world.getBlockState(position).getBlock()))
if(!ArrayUtils.contains(BLACKLIST, Minecraft.getInstance().world.getBlockState(blockResult.getPos()).getBlock()))
{
return position;
return blockResult.getPos();
}
}
return Minecraft.getInstance().player.getPosition();
}
public static boolean isFocusedBlockEqualTo(Block block)
public static Block getFocusedBlock()
{
return getBlock(getFocusedBlockPos()) == block;
return Minecraft.getInstance().world.getBlockState(getFocusedBlockPos()).getBlock();
}
public static Block getBlock(BlockPos pos)
@@ -148,19 +151,19 @@ public class BlockHelper
POS_2_OBSERVERS.add(observer);
}
private static NBTTagCompound newCommandBlock(String command)
private static CompoundNBT newCommandBlock(String command)
{
NBTTagCompound blockState = new NBTTagCompound();
blockState.setString("Name", Blocks.COMMAND_BLOCK.getRegistryName().toString());
CompoundNBT blockState = new CompoundNBT();
blockState.putString("Name", Blocks.COMMAND_BLOCK.getRegistryName().toString());
NBTTagCompound tileEntityData = new NBTTagCompound();
tileEntityData.setString("Command", command);
tileEntityData.setBoolean("auto", true);
CompoundNBT tileEntityData = new CompoundNBT();
tileEntityData.putString("Command", command);
tileEntityData.putBoolean("auto", true);
NBTTagCompound commandBlock = new NBTTagCompound();
commandBlock.setInt("Time", 1);
commandBlock.setTag("BlockState", blockState);
commandBlock.setTag("TileEntityData", tileEntityData);
CompoundNBT commandBlock = new CompoundNBT();
commandBlock.putInt("Time", 1);
commandBlock.put("BlockState", blockState);
commandBlock.put("TileEntityData", tileEntityData);
return commandBlock;
}
@@ -178,28 +181,34 @@ public class BlockHelper
fill.setZ2(new CoordinateInt(0, CoordinateType.GLOBAL));
fill.setBlock1(new BlockResourceLocation(Blocks.AIR.getRegistryName()));
NBTTagCompound block = newCommandBlock(fill.toActualCommand());
block.setString("id", "falling_block");
CompoundNBT executer = newCommandBlock(command);
executer.putString("id", "falling_block");
NBTTagList passengers = new NBTTagList();
passengers.add(block);
ListNBT passengers = new ListNBT();
passengers.add(executer);
NBTTagCompound nbt = newCommandBlock(command);
nbt.setTag("Passengers", passengers);
CompoundNBT remover = newCommandBlock(fill.toActualCommand());
remover.put("Passengers", passengers);
ListNBT motion = new ListNBT();
motion.add(new DoubleNBT(0.0D));
motion.add(new DoubleNBT(0.315D));
motion.add(new DoubleNBT(0.0D));
remover.put("Motion", motion);
Minecraft.getInstance().displayGuiScreen(null);
Minecraft.getInstance().mouseHelper.grabMouse();
BuilderSummon summon = new BuilderSummon();
summon.setEntity(EntityType.FALLING_BLOCK.getRegistryName().toString());
summon.setX(new CoordinateDouble(0.0, CoordinateType.LOCAL));
summon.setY(new CoordinateDouble(0.54, CoordinateType.LOCAL));
summon.setZ(new CoordinateDouble(0.0, CoordinateType.LOCAL));
summon.setNBT(nbt);
summon.setX(new CoordinateDouble(0.0, CoordinateType.GLOBAL));
summon.setY(new CoordinateDouble(0.5, CoordinateType.GLOBAL));
summon.setZ(new CoordinateDouble(0.0, CoordinateType.GLOBAL));
summon.setNBT(remover);
BlockPos pos = Minecraft.getInstance().player.getPosition().add(0, 3, 0);
Minecraft.getInstance().player.sendChatMessage(new BuilderSetBlock(pos, Blocks.COMMAND_BLOCK.getRegistryName(), Config.CLIENT.getSettings().getBlockPlacingMode()).toActualCommand());
Minecraft.getInstance().getConnection().sendPacket(new CPacketUpdateCommandBlock(pos, summon.toActualCommand(false), TileEntityCommandBlock.Mode.REDSTONE, true, false, true));
Minecraft.getInstance().getConnection().sendPacket(new CUpdateCommandBlockPacket(pos, summon.toActualCommand(false), CommandBlockTileEntity.Mode.REDSTONE, true, false, true));
return true;
}
@@ -212,16 +221,16 @@ public class BlockHelper
switch(Minecraft.getInstance().player.getHorizontalFacing())
{
case NORTH:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.SOUTH));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH));
break;
case EAST:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.WEST));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.WEST));
break;
case SOUTH:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.NORTH));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.NORTH));
break;
case WEST:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.EAST));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.EAST));
break;
default:
break;

View File

@@ -9,7 +9,7 @@ import exopandora.worldhandler.command.CommandWH;
import exopandora.worldhandler.command.CommandWorldHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -18,7 +18,7 @@ public class CommandHelper
{
public static void sendFeedback(CommandSource source, String message)
{
source.sendFeedback(new TextComponentString(message), false);
source.sendFeedback(new StringTextComponent(message), false);
}
public static boolean canPlayerIssueCommand()

View File

@@ -10,9 +10,9 @@ import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.potion.Effect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -24,17 +24,17 @@ import net.minecraftforge.registries.IForgeRegistry;
public class RegistryTranslator
{
private static final Map<IForgeRegistry<?>, Function<?, String>> FORGE = new HashMap<IForgeRegistry<?>, Function<?, String>>();
private static final Map<IRegistry<?>, Function<?, String>> VANILLA = new HashMap<IRegistry<?>, Function<?, String>>();
private static final Map<Registry<?>, Function<?, String>> VANILLA = new HashMap<Registry<?>, Function<?, String>>();
static
{
register(ForgeRegistries.BLOCKS, Block::getTranslationKey);
register(ForgeRegistries.ITEMS, Item::getTranslationKey);
register(ForgeRegistries.POTIONS, Potion::getName);
register(ForgeRegistries.POTIONS, Effect::getName);
register(ForgeRegistries.BIOMES, Biome::getTranslationKey);
register(ForgeRegistries.ENCHANTMENTS, Enchantment::getName);
register(ForgeRegistries.ENTITIES, EntityType::getTranslationKey);
register(IRegistry.field_212623_l, stat -> "stat." + stat.toString().replace(':', '.'));
register(Registry.field_212623_l, stat -> "stat." + stat.toString().replace(':', '.'));
}
private static <T extends ForgeRegistryEntry<T>> void register(IForgeRegistry<T> registry, Function<T, String> mapper)
@@ -42,7 +42,7 @@ public class RegistryTranslator
FORGE.put(registry, mapper);
}
private static <T> void register(IRegistry<T> registry, Function<T, String> mapper)
private static <T> void register(Registry<T> registry, Function<T, String> mapper)
{
VANILLA.put(registry, mapper);
}
@@ -59,11 +59,11 @@ public class RegistryTranslator
}
}
for(IRegistry<?> registry : VANILLA.keySet())
for(Registry<?> registry : VANILLA.keySet())
{
if(registry.func_212607_c(resource))
if(registry.containsKey(resource))
{
return ((Function<T, String>) VANILLA.get(registry)).apply((T) registry.func_212608_b(resource));
return ((Function<T, String>) VANILLA.get(registry)).apply((T) registry.getOrDefault(resource));
}
}

View File

@@ -6,17 +6,17 @@ import java.util.function.Function;
import java.util.function.Predicate;
import com.google.common.base.Predicates;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.scoreboard.ScoreCriteria;
import net.minecraft.scoreboard.Team.CollisionRule;
import net.minecraft.scoreboard.Team.EnumVisible;
import net.minecraft.stats.StatList;
import net.minecraft.scoreboard.Team.Visible;
import net.minecraft.stats.StatType;
import net.minecraft.stats.Stats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class ScoreboardHelper
@@ -33,9 +33,8 @@ public class ScoreboardHelper
private void init()
{
//Lists
final List<Node> colors = this.createList(ChatFormatting.values(), ChatFormatting::getName, ChatFormatting::isColor);
final List<Node> visibility = this.createList(EnumVisible.values(), value -> value.internalName);
final List<Node> colors = this.createList(TextFormatting.values(), TextFormatting::getFriendlyName, TextFormatting::isColor);
final List<Node> visibility = this.createList(Visible.values(), value -> value.internalName);
final List<Node> collision = this.createList(CollisionRule.values(), value -> value.name);
final List<Node> bool = this.createList(new Boolean[] {true, false}, String::valueOf);
@@ -48,18 +47,18 @@ public class ScoreboardHelper
this.objectives.merge("minecraft", (parent, child) -> parent + "." + child);
for(StatType<?> type : IRegistry.field_212634_w)
for(StatType<?> type : ForgeRegistries.STAT_TYPES)
{
if(!type.equals(StatList.CUSTOM))
if(!type.equals(Stats.CUSTOM))
{
List<Node> entries = new ArrayList<Node>();
for(ResourceLocation key : type.getRegistry().getKeys())
for(ResourceLocation key : type.getRegistry().keySet())
{
entries.add(new Node(this.buildKey(key)));
}
this.objectives.addNode(this.buildKey(IRegistry.field_212634_w.getKey(type)), entries);
this.objectives.addNode(this.buildKey(ForgeRegistries.STAT_TYPES.getKey(type)), entries);
}
}