diff --git a/gradle.properties b/gradle.properties index c091a2721..513889d4a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,27 +3,27 @@ org.gradle.jvmargs = -Xmx4G # Fabric minecraft_version = 1.16.1 -yarn_mappings = 1.16.1+build.19 +yarn_mappings = 1.16.1+build.21 loader_version = 0.8.9+build.203 #Fabric api -api_version = 0.14.2+build.373-1.16 +api_version = 0.14.1+build.372-1.16 # Mod mod_name = astromine -mod_version = 1.0.30 +mod_version = 1.0.31 mod_group = com.github.chainmailstudios version_meta = fabric-1.16.1 # Dependency cardinal_components_version = 2.4.1 -spinnery_version = 3.0.48+fabric-1.16.x +spinnery_version = 3.0.54+fabric-1.16.x shapes_version = 2.0.0+build.10 patchouli_version = 1.16-37.21-FABRIC lba_version=0.7.0 auto_config_version=3.2.0-unstable # Conveniences -rei_version = 4.6.6 -modmenu_version = 1.12.2+build.17 +rei_version = 4.8.1 +modmenu_version = 1.13.0+build.20 databreaker_version = -SNAPSHOT \ No newline at end of file diff --git a/src/main/java/com/github/chainmailstudios/astromine/client/render/block/HolographicBridgeBlockEntityRenderer.java b/src/main/java/com/github/chainmailstudios/astromine/client/render/block/HolographicBridgeBlockEntityRenderer.java index cfeec3a3c..3798135d2 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/client/render/block/HolographicBridgeBlockEntityRenderer.java +++ b/src/main/java/com/github/chainmailstudios/astromine/client/render/block/HolographicBridgeBlockEntityRenderer.java @@ -3,8 +3,11 @@ import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalFacingBlock; import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.RenderPhase; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -13,6 +16,7 @@ import net.minecraft.util.math.Vec3i; import com.github.chainmailstudios.astromine.AstromineCommon; +import com.github.chainmailstudios.astromine.client.render.layer.Layers; import com.github.chainmailstudios.astromine.common.block.HolographicBridgeProjectorBlock; import com.github.chainmailstudios.astromine.common.block.entity.HolographicBridgeProjectorBlockEntity; import spinnery.client.render.layer.SpinneryLayers; @@ -52,7 +56,7 @@ public void render(HolographicBridgeProjectorBlockEntity entity, float tickDelta matrices.push(); - VertexConsumer c = provider.getBuffer(SpinneryLayers.getInterface()); + VertexConsumer c = provider.getBuffer(Layers.getHolographicBridge()); Color bC = entity.color; diff --git a/src/main/java/com/github/chainmailstudios/astromine/client/render/layer/Layers.java b/src/main/java/com/github/chainmailstudios/astromine/client/render/layer/Layers.java index ea3ccb870..8c2daf2f7 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/client/render/layer/Layers.java +++ b/src/main/java/com/github/chainmailstudios/astromine/client/render/layer/Layers.java @@ -7,6 +7,17 @@ import net.minecraft.util.Identifier; public class Layers extends RenderLayer { + private static final RenderLayer HOLOGRAPHIC_BRIDGE = RenderLayer.of("holographic_bridge", VertexFormats.POSITION_COLOR_LIGHT, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder() + .cull(RenderPhase.DISABLE_CULLING) + .lightmap(ENABLE_LIGHTMAP) + .shadeModel(RenderLayer.SMOOTH_SHADE_MODEL) + .transparency(RenderLayer.TRANSLUCENT_TRANSPARENCY) + .alpha(RenderLayer.ONE_TENTH_ALPHA) + .layering(RenderLayer.VIEW_OFFSET_Z_LAYERING) + //.target(RenderLayer.TRANSLUCENT_TARGET) + .build(false) + ); + public Layers(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, Runnable startAction, Runnable endAction) { super(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, startAction, endAction); } @@ -16,4 +27,8 @@ public static RenderLayer get(Identifier texture) { ONE_TENTH_ALPHA).lightmap(DISABLE_LIGHTMAP).overlay(DISABLE_OVERLAY_COLOR).build(true); return of("entity_cutout", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT, 7, 256, true, true, multiPhaseParameters); } + + public static RenderLayer getHolographicBridge() { + return HOLOGRAPHIC_BRIDGE; + } } diff --git a/src/main/java/com/github/chainmailstudios/astromine/common/block/entity/HolographicBridgeProjectorBlockEntity.java b/src/main/java/com/github/chainmailstudios/astromine/common/block/entity/HolographicBridgeProjectorBlockEntity.java index cdb1e3e6c..7ac1debdd 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/common/block/entity/HolographicBridgeProjectorBlockEntity.java +++ b/src/main/java/com/github/chainmailstudios/astromine/common/block/entity/HolographicBridgeProjectorBlockEntity.java @@ -145,21 +145,21 @@ public boolean buildBridge() { for (Vector3f v : this.segments) { BlockPos nP = new BlockPos(v.getX(), v.getY(), v.getZ()); - Material mat = this.world.getBlockState(nP).getMaterial(); - if(mat.isReplaceable() || mat.equals(HolographicBridgeInvisibleBlock.MATERIAL)) { - if ((nP.getX() != bCP.getX() && nP.getX() != bOP.getX()) || (nP.getZ() != bCP.getZ() && nP.getZ() != bOP.getZ())) { + if ((nP.getX() != bCP.getX() && nP.getX() != bOP.getX()) || (nP.getZ() != bCP.getZ() && nP.getZ() != bOP.getZ())) { + Material mat = this.world.getBlockState(nP).getMaterial(); + if(mat.isReplaceable() || mat.equals(HolographicBridgeInvisibleBlock.MATERIAL)) { this.world.setBlockState(nP, AstromineBlocks.HOLOGRAPHIC_BRIDGE_INVISIBLE_BLOCK.getDefaultState()); this.members.add(nP); - } - ComponentProvider componentProvider = ComponentProvider.fromWorld(world); + ComponentProvider componentProvider = ComponentProvider.fromWorld(world); - WorldBridgeComponent bridgeComponent = componentProvider.getComponent(AstromineComponentTypes.WORLD_BRIDGE_COMPONENT); + WorldBridgeComponent bridgeComponent = componentProvider.getComponent(AstromineComponentTypes.WORLD_BRIDGE_COMPONENT); - bridgeComponent.add(nP, new Vec3i((v.getX() - (int) v.getX()) * 16f, (v.getY() - (int) v.getY()) * 16f, (v.getZ() - (int) v.getZ()) * 16f)); - } else { - destroyBridge(); - return false; + bridgeComponent.add(nP, new Vec3i((v.getX() - (int) v.getX()) * 16f, (v.getY() - (int) v.getY()) * 16f, (v.getZ() - (int) v.getZ()) * 16f)); + } else { + destroyBridge(); + return false; + } } } if(!world.isClient()) { diff --git a/src/main/java/com/github/chainmailstudios/astromine/common/entity/SpaceSlimeEntity.java b/src/main/java/com/github/chainmailstudios/astromine/common/entity/SpaceSlimeEntity.java index 825b9de66..95beb2414 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/common/entity/SpaceSlimeEntity.java +++ b/src/main/java/com/github/chainmailstudios/astromine/common/entity/SpaceSlimeEntity.java @@ -7,6 +7,8 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.entity.mob.SlimeEntity; import net.minecraft.particle.ParticleEffect; +import net.minecraft.sound.SoundEvent; +import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.Difficulty; import net.minecraft.world.LightType; @@ -102,4 +104,9 @@ public static boolean isSpawnDark(WorldAccess world, BlockPos pos, Random random return i <= random.nextInt(8); } } + + @Override + public SoundEvent getSquishSound() { + return SoundEvents.BLOCK_GLASS_BREAK; + } } diff --git a/src/main/java/com/github/chainmailstudios/astromine/common/item/FireExtinguisherItem.java b/src/main/java/com/github/chainmailstudios/astromine/common/item/FireExtinguisherItem.java index 7035c9e20..a540ae34a 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/common/item/FireExtinguisherItem.java +++ b/src/main/java/com/github/chainmailstudios/astromine/common/item/FireExtinguisherItem.java @@ -40,7 +40,7 @@ public ActionResult useOnBlock(ItemUsageContext context) { public TypedActionResult use(World world, PlayerEntity user, Hand hand) { Vec3d placeVec = user.getCameraPosVec(0); - Vec3d thrustVec = new Vec3d(0.5, 0.5, 0.5); + Vec3d thrustVec = new Vec3d(0.8, 0.8, 0.8); thrustVec = thrustVec.multiply(user.getRotationVector()); @@ -53,9 +53,9 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han if (!user.isSneaking()) { user.addVelocity(thrustVec.x, thrustVec.y, thrustVec.z); - user.getItemCooldownManager().set(this, 20); + user.getItemCooldownManager().set(this, 10); } else { - user.getItemCooldownManager().set(this, 5); + user.getItemCooldownManager().set(this, 2); } BlockHitResult result = (BlockHitResult) user.rayTrace(6, 0, false); @@ -63,11 +63,11 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han BlockPos.Mutable.method_29715(new Box(result.getBlockPos()).expand(1)).forEach(position -> { BlockState state = world.getBlockState(position); - state.getEntries().keySet().stream().filter(property -> property == FireBlock.EAST || property == FireBlock.WEST || property == FireBlock.NORTH || property == FireBlock.SOUTH || property == FireBlock.UP).forEach(property -> world.setBlockState( - position, - Blocks.AIR.getDefaultState() - )); - state.getEntries().keySet().stream().filter(property -> property == CampfireBlock.LIT).forEach(property -> world.setBlockState(position, world.getBlockState(position).with(CampfireBlock.LIT, false))); + if(state.getBlock() instanceof FireBlock) { + world.setBlockState(position, Blocks.AIR.getDefaultState()); + } else if(state.getBlock() instanceof CampfireBlock) { + if(state.get(CampfireBlock.LIT)) world.setBlockState(position, state.with(CampfireBlock.LIT, false)); + } }); world.getEntities(null, new Box(result.getBlockPos()).expand(1)).forEach(entity -> { diff --git a/src/main/java/com/github/chainmailstudios/astromine/common/utilities/PacketUtilities.java b/src/main/java/com/github/chainmailstudios/astromine/common/utilities/PacketUtilities.java index 9ce038cb0..10861a171 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/common/utilities/PacketUtilities.java +++ b/src/main/java/com/github/chainmailstudios/astromine/common/utilities/PacketUtilities.java @@ -1 +1,83 @@ -package com.github.chainmailstudios.astromine.common.utilities; import net.minecraft.network.PacketByteBuf; import net.minecraft.util.Identifier; import com.github.chainmailstudios.astromine.AstromineCommon; import org.apache.logging.log4j.Level; import com.google.common.collect.ImmutableMap; import java.util.HashMap; import java.util.Map; import java.util.function.BiConsumer; import java.util.function.BiFunction; public class PacketUtilities { private static final ImmutableMap, BiConsumer> WRITERS = ImmutableMap., BiConsumer>builder().put(Integer.class, (buffer, object) -> { buffer.writeInt((Integer) object); }).put(Float.class, (buffer, object) -> { buffer.writeFloat((Float) object); }).put(Double.class, (buffer, object) -> { buffer.writeDouble((Double) object); }).put(String.class, (buffer, object) -> { buffer.writeString((String) object); }).put(Identifier.class, (buffer, object) -> { buffer.writeIdentifier((Identifier) object); }).put(Enum.class, (buffer, object) -> { buffer.writeEnumConstant((Enum) object); }).build(); private static final ImmutableMap, BiFunction, ?>> READERS = ImmutableMap., BiFunction, ?>>builder().put(Integer.class, (buffer, object) -> { return buffer.readInt(); }).put(Float.class, (buffer, object) -> { return buffer.readFloat(); }).put(Double.class, (buffer, object) -> { return buffer.readDouble(); }).put(String.class, (buffer, object) -> { return buffer.readString(); }).put(Identifier.class, (buffer, object) -> { return buffer.readIdentifier(); }).put(Enum.class, (buffer, object) -> { return buffer.readEnumConstant(((Enum) (object.getEnumConstants()[0])).getClass()); }).build(); public static void toPacket(PacketByteBuf buffer, Object object) { writeObject(buffer, object); } public static void writeObject(PacketByteBuf buffer, Object object) { if (WRITERS.containsKey(object.getClass())) { WRITERS.get(object.getClass()).accept(buffer, object); } else { AstromineCommon.LOGGER.log(Level.ERROR, "Packet serialization failed: " + object.getClass().getName() + " is not a valid class!"); } } public static void toPacket(PacketByteBuf buffer, HashMap map) { writeObject(buffer, map.size()); for (Map.Entry entry : map.entrySet()) { writeObject(buffer, entry.getKey()); writeObject(buffer, entry.getValue()); } } public static K fromPacket(PacketByteBuf buffer, Class k) { return (K) readObject(buffer, k); } public static Object readObject(PacketByteBuf buffer, Class object) { if (READERS.containsKey(object)) { return READERS.get(object).apply(buffer, object); } else { AstromineCommon.LOGGER.log(Level.ERROR, "Packet serialization failed: " + object.getClass() + " is not a valid class!"); return null; } } public static HashMap fromPacket(PacketByteBuf buffer, Class k, Class v) { HashMap map = new HashMap(); int size = buffer.readInt(); for (int i = 0; i < size; ++i) { map.put((K) readObject(buffer, k), (V) readObject(buffer, v)); } return map; } } \ No newline at end of file +package com.github.chainmailstudios.astromine.common.utilities; + +import net.minecraft.network.PacketByteBuf; +import net.minecraft.util.Identifier; + +import com.github.chainmailstudios.astromine.AstromineCommon; +import org.apache.logging.log4j.Level; + +import com.google.common.collect.ImmutableMap; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; + +public class PacketUtilities { + private static final ImmutableMap, BiConsumer> WRITERS = ImmutableMap., BiConsumer>builder().put(Integer.class, (buffer, object) -> + buffer.writeInt((Integer) object) + ).put(Float.class, (buffer, object) -> + buffer.writeFloat((Float) object) + ).put(Double.class, (buffer, object) -> + buffer.writeDouble((Double) object) + ).put(String.class, (buffer, object) -> + buffer.writeString((String) object) + ).put(Identifier.class, (buffer, object) -> + buffer.writeIdentifier((Identifier) object) + ).put(Enum.class, (buffer, object) -> + buffer.writeEnumConstant((Enum) object) + ).build(); + + private static final ImmutableMap, BiFunction, ?>> READERS = ImmutableMap., BiFunction, ?>>builder().put(Integer.class, (buffer, object) -> buffer.readInt()).put(Float.class, (buffer, object) -> + buffer.readFloat() + ).put(Double.class, (buffer, object) -> + buffer.readDouble() + ).put(String.class, (buffer, object) -> + buffer.readString() + ).put(Identifier.class, (buffer, object) -> + buffer.readIdentifier() + ).put(Enum.class, (buffer, object) -> + buffer.readEnumConstant(((Enum) (object.getEnumConstants()[0])).getClass()) + ).build(); + + public static void toPacket(PacketByteBuf buffer, Object object) { + writeObject(buffer, object); + } + + public static void writeObject(PacketByteBuf buffer, Object object) { + if (WRITERS.containsKey(object.getClass())) { + WRITERS.get(object.getClass()).accept(buffer, object); + } else { + AstromineCommon.LOGGER.log(Level.ERROR, "Packet serialization failed: " + object.getClass().getName() + " is not a valid class!"); + } + } + + public static void toPacket(PacketByteBuf buffer, HashMap map) { + writeObject(buffer, map.size()); + for (Map.Entry entry : map.entrySet()) { + writeObject(buffer, entry.getKey()); + writeObject(buffer, entry.getValue()); + } + } + + public static K fromPacket(PacketByteBuf buffer, Class k) { + return (K) readObject(buffer, k); + } + + public static Object readObject(PacketByteBuf buffer, Class object) { + if (READERS.containsKey(object)) { + return READERS.get(object).apply(buffer, object); + } else { + AstromineCommon.LOGGER.log(Level.ERROR, "Packet serialization failed: " + object.getClass() + " is not a valid class!"); + return null; + } + } + + public static HashMap fromPacket(PacketByteBuf buffer, Class k, Class v) { + HashMap map = new HashMap(); + int size = buffer.readInt(); + for (int i = 0; i < size; ++i) { + map.put((K) readObject(buffer, k), (V) readObject(buffer, v)); + } + return map; + } +} diff --git a/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFluidVolumeFractionalVerticalBar.java b/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFluidVolumeFractionalVerticalBar.java index cf8f5feba..bbe076607 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFluidVolumeFractionalVerticalBar.java +++ b/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFluidVolumeFractionalVerticalBar.java @@ -79,11 +79,11 @@ public void draw(MatrixStack matrices, VertexConsumerProvider.Immediate provider } if (isFocused()) { - getTooltipText().clear(); + getTooltip().clear(); - getTooltipText().add(FluidUtilities.rawFraction(getProgressFraction().get(), getLimitFraction().get(), getUnit())); + getTooltip().add(FluidUtilities.rawFraction(getProgressFraction().get(), getLimitFraction().get(), getUnit())); - getTooltipText().add(new TranslatableText("text.astromine.tooltip.fractional_value", getProgressFraction().get().toPrettyString(), getLimitFraction().get().toPrettyString())); + getTooltip().add(new TranslatableText("text.astromine.tooltip.fractional_value", getProgressFraction().get().toPrettyString(), getLimitFraction().get().toPrettyString())); drawTooltips(matrices, provider); } diff --git a/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFractionalVerticalBar.java b/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFractionalVerticalBar.java index d478629d9..40773c58b 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFractionalVerticalBar.java +++ b/src/main/java/com/github/chainmailstudios/astromine/common/widget/WFractionalVerticalBar.java @@ -65,11 +65,7 @@ public W setUnit(Text unit) { return (W) this; } - public WTooltip getTooltip() { - return tooltip; - } - - public List getTooltipText() { + public List getTooltip() { return tooltipText; } @@ -140,7 +136,7 @@ protected void drawTooltips(MatrixStack matrices, VertexConsumerProvider.Immedia float lineY = position.getY(); float lineZ = position.getZ(); for (Text text : tooltipText) { - TextRenderer.pass().text(text).font(TextRenderer.Font.DEFAULT).at(lineX, lineY, lineZ).scale(1.0D).maxWidth(null).render(matrices, provider); + TextRenderer.pass().text(text).at(lineX, lineY, lineZ).scale(1.0f).render(matrices, provider); lineY += TextRenderer.height(); } diff --git a/src/main/java/com/github/chainmailstudios/astromine/mixin/FlamingAnvilCraftingMixin.java b/src/main/java/com/github/chainmailstudios/astromine/mixin/FlamingAnvilCraftingMixin.java index 44ace3e05..b73be6bd2 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/mixin/FlamingAnvilCraftingMixin.java +++ b/src/main/java/com/github/chainmailstudios/astromine/mixin/FlamingAnvilCraftingMixin.java @@ -47,7 +47,7 @@ private void ret(CallbackInfoReturnable cir) { @Inject(method = "handleFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/tag/Tag;)Z"), locals = LocalCapture.CAPTURE_FAILHARD) private void handle(float fallDistance, float damageMultiplier, CallbackInfoReturnable cir, int i, List list) { - if (this.isOnFire()) { + if (this.isOnFire() && this.block.isIn(BlockTags.ANVIL)) { Iterator iterator = list.iterator(); while (iterator.hasNext()) { Entity entity = iterator.next(); diff --git a/src/main/java/com/github/chainmailstudios/astromine/mixin/HoneyBlockMixin.java b/src/main/java/com/github/chainmailstudios/astromine/mixin/HoneyBlockMixin.java index 75633d8b9..3e6c878cd 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/mixin/HoneyBlockMixin.java +++ b/src/main/java/com/github/chainmailstudios/astromine/mixin/HoneyBlockMixin.java @@ -6,6 +6,7 @@ import net.minecraft.block.HoneyBlock; import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.github.chainmailstudios.astromine.common.registry.GravityRegistry; @@ -13,9 +14,7 @@ @Mixin(HoneyBlock.class) public class HoneyBlockMixin { @ModifyConstant(method = "isSliding(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/Entity;)Z", constant = @Constant(doubleValue = -0.08D)) - double getGravity(double original) { - World world = ((Entity) (Object) this).world; - - return -GravityRegistry.INSTANCE.get(world.getDimensionRegistryKey()); + double getGravity(double original, BlockPos pos, Entity entity) { + return -GravityRegistry.INSTANCE.get(entity.world.getDimensionRegistryKey()); } } diff --git a/src/main/java/com/github/chainmailstudios/astromine/mixin/InGameHudMixin.java b/src/main/java/com/github/chainmailstudios/astromine/mixin/InGameHudMixin.java index 5b839a2d5..722a1f8d8 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/mixin/InGameHudMixin.java +++ b/src/main/java/com/github/chainmailstudios/astromine/mixin/InGameHudMixin.java @@ -9,7 +9,10 @@ import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import com.github.chainmailstudios.astromine.common.item.SpaceSuitItem; import com.github.chainmailstudios.astromine.registry.client.AstromineScreens; import spinnery.widget.api.Position; @@ -23,15 +26,25 @@ public class InGameHudMixin { */ @Inject(at = @At("RETURN"), method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V") void astromine_onRender(MatrixStack matrices, float f, CallbackInfo callbackInformation) { - int height = MinecraftClient.getInstance().getWindow().getScaledHeight(); - - if (height != lastHeight) { - lastHeight = height; - AstromineScreens.GAS_IMAGE.setPosition(Position.of(0, height - 18, 0)); + if(MinecraftClient.getInstance().getCameraEntity() instanceof LivingEntity) { + if(((LivingEntity)MinecraftClient.getInstance().getCameraEntity()).getEquippedStack(EquipmentSlot.HEAD).getItem() instanceof SpaceSuitItem) { + if(AstromineScreens.GAS_IMAGE.isHidden()) { + AstromineScreens.GAS_IMAGE.setHidden(false); + } + int height = MinecraftClient.getInstance().getWindow().getScaledHeight(); + if (height != lastHeight) { + lastHeight = height; + AstromineScreens.GAS_IMAGE.setPosition(Position.of(0, height - 18, 0)); + } + + VertexConsumerProvider.Immediate provider = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); + + AstromineScreens.GAS_IMAGE.draw(matrices, provider); + } else { + if(!AstromineScreens.GAS_IMAGE.isHidden()) { + AstromineScreens.GAS_IMAGE.setHidden(true); + } + } } - - VertexConsumerProvider.Immediate provider = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); - - AstromineScreens.GAS_IMAGE.draw(matrices, provider); } } diff --git a/src/main/java/com/github/chainmailstudios/astromine/mixin/LivingEntityMixin.java b/src/main/java/com/github/chainmailstudios/astromine/mixin/LivingEntityMixin.java index fe9361b8a..ad7b594a6 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/mixin/LivingEntityMixin.java +++ b/src/main/java/com/github/chainmailstudios/astromine/mixin/LivingEntityMixin.java @@ -106,7 +106,7 @@ void onTick(CallbackInfo callbackInformation) { Block downBlock = downState.getBlock(); if (upBlock instanceof FluidBlock) { - FluidState fluidState = upBlock.getFluidState(upState); + FluidState fluidState = upState.getFluidState(); fluid = fluidState.getFluid(); diff --git a/src/main/java/com/github/chainmailstudios/astromine/mixin/SlimeEntityMixin.java b/src/main/java/com/github/chainmailstudios/astromine/mixin/SlimeEntityMixin.java deleted file mode 100644 index c4ffa3196..000000000 --- a/src/main/java/com/github/chainmailstudios/astromine/mixin/SlimeEntityMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.chainmailstudios.astromine.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import net.minecraft.entity.EntityType; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.mob.SlimeEntity; -import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; -import net.minecraft.world.World; - -import com.github.chainmailstudios.astromine.common.entity.SpaceSlimeEntity; - -@Mixin(SlimeEntity.class) -public abstract class SlimeEntityMixin extends MobEntity { - - private SlimeEntityMixin(EntityType entityType, World world) { - super(entityType, world); - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/SlimeEntity;playSound(Lnet/minecraft/sound/SoundEvent;FF)V")) - private void playDoubleSound(SlimeEntity slimeEntity, SoundEvent sound, float volume, float pitch) { - if ((Object) this instanceof SpaceSlimeEntity) { - this.playSound(SoundEvents.BLOCK_GLASS_BREAK, this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); - } else { - this.playSound(this.getSquishSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); - } - } - - @Shadow - protected abstract SoundEvent getSquishSound(); -} diff --git a/src/main/java/com/github/chainmailstudios/astromine/mixin/StepAndDestroyBlockGoalMixin.java b/src/main/java/com/github/chainmailstudios/astromine/mixin/StepAndDestroyBlockGoalMixin.java index f6de43688..ffd6285f2 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/mixin/StepAndDestroyBlockGoalMixin.java +++ b/src/main/java/com/github/chainmailstudios/astromine/mixin/StepAndDestroyBlockGoalMixin.java @@ -1,20 +1,25 @@ package com.github.chainmailstudios.astromine.mixin; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; import net.minecraft.entity.Entity; import net.minecraft.entity.ai.goal.StepAndDestroyBlockGoal; +import net.minecraft.entity.mob.MobEntity; import net.minecraft.world.World; import com.github.chainmailstudios.astromine.common.registry.GravityRegistry; @Mixin(StepAndDestroyBlockGoal.class) public class StepAndDestroyBlockGoalMixin { + @Shadow @Final private MobEntity stepAndDestroyMob; + @ModifyConstant(method = "tick()V", constant = @Constant(doubleValue = 0.08D)) double getGravity(double original) { - World world = ((Entity) (Object) this).world; + World world = stepAndDestroyMob.world; return GravityRegistry.INSTANCE.get(world.getDimensionRegistryKey()); } diff --git a/src/main/java/com/github/chainmailstudios/astromine/registry/client/AstromineScreens.java b/src/main/java/com/github/chainmailstudios/astromine/registry/client/AstromineScreens.java index b8ffecf4b..e8970c870 100644 --- a/src/main/java/com/github/chainmailstudios/astromine/registry/client/AstromineScreens.java +++ b/src/main/java/com/github/chainmailstudios/astromine/registry/client/AstromineScreens.java @@ -6,6 +6,8 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; +import net.minecraft.client.MinecraftClient; + import com.github.chainmailstudios.astromine.AstromineCommon; import com.github.chainmailstudios.astromine.registry.AstromineContainers; import spinnery.client.screen.InGameHudScreen; @@ -22,59 +24,61 @@ public static void initialize() { InGameHudScreen.addOnInitialize(() -> { WInterface mainInterface = InGameHudScreen.getInterface(); - GAS_IMAGE = mainInterface.createChild(WStaticImage::new, Position.of(0, 4, 0), Size.of(16, 16)).setTexture(AstromineCommon.identifier("textures/symbol/oxygen.png")); + GAS_IMAGE = mainInterface.createChild(WStaticImage::new, Position.of(0, MinecraftClient.getInstance().getWindow().getScaledHeight() - 18, 0), Size.of(16, 16)).setTexture(AstromineCommon.identifier("textures/symbol/oxygen.png")); + GAS_IMAGE.setHidden(true); }); - ScreenRegistry.register(AstromineContainers.FLUID_EXTRACTOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new FluidExtractorContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.FLUID_EXTRACTOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new FluidExtractorContainerScreen(title, handler, inventory.player) + )); + + ScreenRegistry.register(AstromineContainers.LIQUID_GENERATOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new LiquidGeneratorContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.LIQUID_GENERATOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new LiquidGeneratorContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.VENT, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new VentContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.VENT, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new VentContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.TANK, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new TankContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.TANK, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new TankContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.NUCLEAR_WARHEAD, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new NuclearWarheadContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.NUCLEAR_WARHEAD, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new NuclearWarheadContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.CREATIVE_CAPACITOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new CreativeCapacitorContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.CREATIVE_CAPACITOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new CreativeCapacitorContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.CREATIVE_TANK, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new CreativeTankContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.CREATIVE_TANK, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new CreativeTankContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.CREATIVE_BUFFER, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new CreativeBufferContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.CREATIVE_BUFFER, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new CreativeBufferContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.SORTER, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new SorterContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.SORTER, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new SorterContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.ELECTRIC_SMELTER, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new SmelterContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.ELECTRIC_SMELTER, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new SmelterContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.ELECTROLYZER, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new ElectrolyzerContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.ELECTROLYZER, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new ElectrolyzerContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.FUEL_MIXER, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new FuelMixerContainerScreen(title, handler, inventory.player) + )); - ScreenRegistry.register(AstromineContainers.FUEL_MIXER, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new FuelMixerContainerScreen(title, handler, inventory.player); - })); - ScreenRegistry.register(AstromineContainers.CRAFTING_RECIPE_CREATOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> { - return new CraftingRecipeCreatorContainerScreen(title, handler, inventory.player); - })); + ScreenRegistry.register(AstromineContainers.CRAFTING_RECIPE_CREATOR, (ScreenRegistry.Factory) ((handler, inventory, title) -> + new CraftingRecipeCreatorContainerScreen(title, handler, inventory.player) + )); } } diff --git a/src/main/resources/astromine.mixins.json b/src/main/resources/astromine.mixins.json index df38ce9d4..2347a781f 100644 --- a/src/main/resources/astromine.mixins.json +++ b/src/main/resources/astromine.mixins.json @@ -5,8 +5,8 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "AbstractMinecartEntityMixin", "BrewingRecipeRegistryMixin", "BucketItemMixin", "DyeColorMixin", "EntityMixin", - "FishingBobberEntityMixin", "FlamingAnvilCraftingMixin", "GravityEntityMixin", - "HopperBlockEntityMixin", "ItemEntityMixin", "LivingEntityMixin", "SlimeEntityMixin", "SquidEntityMixin", + "FishingBobberEntityMixin", "FlamingAnvilCraftingMixin", "GravityEntityMixin", "HoneyBlockMixin", + "HopperBlockEntityMixin", "ItemEntityMixin", "LivingEntityMixin", "SquidEntityMixin", "StepAndDestroyBlockGoalMixin", "ThreadExecutorMixin", "WorldChunkMixin" ], "client": [