Skip to content

Commit

Permalink
Merge pull request #149 from Chainmail-Studios/shnup
Browse files Browse the repository at this point in the history
1.0.31
  • Loading branch information
Shnupbups authored Jul 11, 2020
2 parents 72bfdcc + 91ce867 commit 830bdca
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 128 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
public TypedActionResult<ItemStack> 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());

Expand All @@ -53,21 +53,21 @@ public TypedActionResult<ItemStack> 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);

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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Class<?>, BiConsumer<PacketByteBuf, Object>> WRITERS = ImmutableMap.<Class<?>, BiConsumer<PacketByteBuf, Object>>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<Class<?>, BiFunction<PacketByteBuf, Class<?>, ?>> READERS = ImmutableMap.<Class<?>, BiFunction<PacketByteBuf, Class<?>, ?>>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> K fromPacket(PacketByteBuf buffer, Class<K> 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 <K, V> HashMap<K, V> fromPacket(PacketByteBuf buffer, Class<K> k, Class<V> v) { HashMap<K, V> map = new HashMap<K, V>(); int size = buffer.readInt(); for (int i = 0; i < size; ++i) { map.put((K) readObject(buffer, k), (V) readObject(buffer, v)); } return map; }}
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<Class<?>, BiConsumer<PacketByteBuf, Object>> WRITERS = ImmutableMap.<Class<?>, BiConsumer<PacketByteBuf, Object>>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<Class<?>, BiFunction<PacketByteBuf, Class<?>, ?>> READERS = ImmutableMap.<Class<?>, BiFunction<PacketByteBuf, Class<?>, ?>>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> K fromPacket(PacketByteBuf buffer, Class<K> 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 <K, V> HashMap<K, V> fromPacket(PacketByteBuf buffer, Class<K> k, Class<V> v) {
HashMap<K, V> map = new HashMap<K, V>();
int size = buffer.readInt();
for (int i = 0; i < size; ++i) {
map.put((K) readObject(buffer, k), (V) readObject(buffer, v));
}
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public <W extends WFractionalVerticalBar> W setUnit(Text unit) {
return (W) this;
}

public WTooltip getTooltip() {
return tooltip;
}

public List<Text> getTooltipText() {
public List<Text> getTooltip() {
return tooltipText;
}

Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void ret(CallbackInfoReturnable<Boolean> 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<Boolean> cir, int i, List<Entity> list) {
if (this.isOnFire()) {
if (this.isOnFire() && this.block.isIn(BlockTags.ANVIL)) {
Iterator<Entity> iterator = list.iterator();
while (iterator.hasNext()) {
Entity entity = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

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;

@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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 830bdca

Please sign in to comment.