Gradle Mondays

- Replaced ponderworld particle AT with reflection
- Symmetry Wand now checks for placement permissions
- Lang now uses Locale.ROOT
- Fixed crash using ponder without advanced tooltips enabled
This commit is contained in:
simibubi 2021-03-08 22:12:25 +01:00
parent bea60ccb86
commit 6c8fe67fd4
5 changed files with 29 additions and 14 deletions

View File

@ -21,6 +21,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -38,6 +39,9 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.Constants.BlockFlags;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
@ -227,7 +231,15 @@ public class SymmetryWandItem extends Item {
if (BlockHelper.findAndRemoveInInventory(blockState, player, 1) == 0) if (BlockHelper.findAndRemoveInInventory(blockState, player, 1) == 0)
continue; continue;
BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, position);
IFluidState ifluidstate = world.getFluidState(position);
world.setBlockState(position, ifluidstate.getBlockState(), BlockFlags.UPDATE_NEIGHBORS);
world.setBlockState(position, blockState); world.setBlockState(position, blockState);
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) {
blocksnapshot.restore(true, false);
continue;
}
targets.add(position); targets.add(position);
} }
} }

View File

@ -98,12 +98,13 @@ public class PonderTooltipHandler {
float renderPartialTicks = AnimationTickHolder.getPartialTicks(); float renderPartialTicks = AnimationTickHolder.getPartialTicks();
if (lastHoveredStack != stack) if (lastHoveredStack != stack)
return; return;
if (subject) { ITextComponent component = subject ? Lang.createTranslationTextComponent(SUBJECT)
toolTip.set(1, Lang.createTranslationTextComponent(SUBJECT) .applyTextStyle(TextFormatting.GREEN)
.applyTextStyle(TextFormatting.GREEN)); : makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f));
return; if (toolTip.size() < 2)
} toolTip.add(component);
toolTip.set(1, makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f))); else
toolTip.set(1, component);
} }
public static void handleTooltipColor(RenderTooltipEvent.Color event) { public static void handleTooltipColor(RenderTooltipEvent.Color event) {

View File

@ -42,6 +42,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.LightType; import net.minecraft.world.LightType;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
public class PonderWorld extends SchematicWorld { public class PonderWorld extends SchematicWorld {
@ -49,7 +50,9 @@ public class PonderWorld extends SchematicWorld {
protected Map<BlockPos, BlockState> originalBlocks; protected Map<BlockPos, BlockState> originalBlocks;
protected Map<BlockPos, TileEntity> originalTileEntities; protected Map<BlockPos, TileEntity> originalTileEntities;
protected List<Entity> originalEntities; protected List<Entity> originalEntities;
protected PonderWorldParticles particles; protected PonderWorldParticles particles;
private final Map<ResourceLocation, IParticleFactory<?>> particleFactories;
int overrideLight; int overrideLight;
Selection mask; Selection mask;
@ -60,6 +63,10 @@ public class PonderWorld extends SchematicWorld {
originalTileEntities = new HashMap<>(); originalTileEntities = new HashMap<>();
originalEntities = new ArrayList<>(); originalEntities = new ArrayList<>();
particles = new PonderWorldParticles(this); particles = new PonderWorldParticles(this);
// ParticleManager.factories - ATs don't seem to like this one
particleFactories = ObfuscationReflectionHelper.getPrivateValue(ParticleManager.class,
Minecraft.getInstance().particles, "field_178932_g");
} }
public void createBackup() { public void createBackup() {
@ -186,9 +193,8 @@ public class PonderWorld extends SchematicWorld {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T extends IParticleData> Particle makeParticle(T data, double x, double y, double z, double mx, double my, private <T extends IParticleData> Particle makeParticle(T data, double x, double y, double z, double mx, double my,
double mz) { double mz) {
ParticleManager particleManager = Minecraft.getInstance().particles;
ResourceLocation key = ForgeRegistries.PARTICLE_TYPES.getKey(data.getType()); ResourceLocation key = ForgeRegistries.PARTICLE_TYPES.getKey(data.getType());
IParticleFactory<T> iparticlefactory = (IParticleFactory<T>) particleManager.factories.get(key); IParticleFactory<T> iparticlefactory = (IParticleFactory<T>) particleFactories.get(key);
return iparticlefactory == null ? null : iparticlefactory.makeParticle(data, this, x, y, z, mx, my, mz); return iparticlefactory == null ? null : iparticlefactory.makeParticle(data, this, x, y, z, mx, my, mz);
} }

View File

@ -25,14 +25,13 @@ public class Lang {
public static List<String> translatedOptions(String prefix, String... keys) { public static List<String> translatedOptions(String prefix, String... keys) {
List<String> result = new ArrayList<>(keys.length); List<String> result = new ArrayList<>(keys.length);
for (String key : keys) { for (String key : keys)
result.add(translate(prefix + "." + key)); result.add(translate(prefix + "." + key));
}
return result; return result;
} }
public static String asId(String name) { public static String asId(String name) {
return name.toLowerCase(Locale.ENGLISH); return name.toLowerCase(Locale.ROOT);
} }
} }

View File

@ -25,9 +25,6 @@ public net.minecraft.tileentity.BeaconTileEntity field_174909_f # beamSegments
public net.minecraft.world.server.ServerTickList field_205374_d # pendingTickListEntriesHashSet public net.minecraft.world.server.ServerTickList field_205374_d # pendingTickListEntriesHashSet
public net.minecraft.world.server.ServerTickList field_205375_e # pendingTickListEntriesTreeSet public net.minecraft.world.server.ServerTickList field_205375_e # pendingTickListEntriesTreeSet
# Particle Manager
public net.minecraft.client.particle.ParticleManager field_178932_g # factories
# Lightmap information for instanced rendering # Lightmap information for instanced rendering
public net.minecraft.client.renderer.LightTexture field_205112_c #resourceLocation public net.minecraft.client.renderer.LightTexture field_205112_c #resourceLocation
public net.minecraft.client.Minecraft field_193996_ah #renderPartialTicksPaused public net.minecraft.client.Minecraft field_193996_ah #renderPartialTicksPaused