Skip to content

Commit

Permalink
Merge pull request #368 from SymmetricDevs/bru-gas-masks
Browse files Browse the repository at this point in the history
Environmental Survival items
  • Loading branch information
bruberu authored Jan 13, 2025
2 parents 03707ab + 82f7570 commit 4659c52
Show file tree
Hide file tree
Showing 166 changed files with 4,218 additions and 19 deletions.
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ dependencies {
implementation rfg.deobf("curse.maven:groovyscript-687577:5507936") // GRS 1.1.1
implementation rfg.deobf("curse.maven:modularui-624243:5153413")

runtimeOnly rfg.deobf("curse.maven:the-beneath-254629:3425551")

compileOnly rfg.deobf("curse.maven:ynet-an-xnet-fork-999559:5243319") // XNet-1.8.3-ynet
compileOnly rfg.deobf("curse.maven:rftools-224641:2861573") // RFTools 7.73
compileOnly rfg.deobf("curse.maven:mcjtylib-233105:2745846")
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/supersymmetry/Supersymmetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import supersymmetry.common.command.CommandHordeStatus;
import supersymmetry.common.command.CommandHordeStop;
import supersymmetry.common.covers.SuSyCoverBehaviors;
import supersymmetry.common.event.DimensionBreathabilityHandler;
import supersymmetry.common.item.SuSyMetaItems;
import supersymmetry.common.metatileentities.SuSyMetaTileEntities;
import supersymmetry.loaders.SuSyIRLoader;
Expand Down Expand Up @@ -65,6 +66,8 @@ public void onPreInit(@NotNull FMLPreInitializationEvent event) {
if (FMLLaunchHandler.side() == Side.CLIENT) {
OBJLoader.INSTANCE.addDomain(MODID);
}

DimensionBreathabilityHandler.loadConfig();
}

@Mod.EventHandler
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/supersymmetry/api/event/MobHordeEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public boolean spawnMobWithoutPod(EntityPlayer player, Consumer<UUID> uuidConsum
Block block = blockstate.getBlock();

mob.setPosition(x, y, z);
while ((!mob.getCanSpawnHere() || !mob.isNotColliding() || block.isAir(blockstate, player.world, pos))
while ((!mob.getCanSpawnHere() || !mob.isNotColliding() || block.isAir(blockstate, player.world, pos))
&& (Math.abs(mob.posY - player.posY) < 8)) {
mob.setPosition(x, mob.posY - 1, z);
pos = new BlockPos(x, mob.posY - 1, z);
Expand Down
69 changes: 69 additions & 0 deletions src/main/java/supersymmetry/api/items/IBreathingArmorLogic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package supersymmetry.api.items;

import gregtech.api.items.armor.ArmorMetaItem;
import gregtech.api.items.armor.IArmorLogic;
import gregtech.api.items.armor.ISpecialArmorLogic;
import gregtech.api.items.metaitem.stats.IItemBehaviour;
import gregtech.common.items.behaviors.TooltipBehavior;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.common.ISpecialArmor;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public interface IBreathingArmorLogic extends ISpecialArmorLogic {

boolean mayBreatheWith(ItemStack stack, EntityPlayer player);


double tryTick(ItemStack stack, EntityPlayer player);

default ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, @NotNull ItemStack armor, DamageSource source, double damage,
EntityEquipmentSlot equipmentSlot) {
return new ISpecialArmor.ArmorProperties(0, 0, (int) player.getMaxHealth());
}

default int getArmorDisplay(EntityPlayer player, @NotNull ItemStack armor, int slot) {
return 0;
}

void addInformation(ItemStack stack, List<String> tooltips);

@Override
default void addToolComponents(ArmorMetaItem.ArmorMetaValueItem metaValueItem) {
metaValueItem.addComponents(new TooltipBehavior((ignored) -> {
}) {
@Override
public void addInformation(ItemStack itemStack, @NotNull List<String> lines) {
IBreathingArmorLogic.this.addInformation(itemStack, lines);
}
}, new IItemBehaviour() {

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
return onRightClick(world, player, hand);
}
});
}

default ActionResult<ItemStack> onRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player.getHeldItem(hand).getItem() instanceof ArmorMetaItem) {
ItemStack armor = player.getHeldItem(hand);
if (armor.getItem() instanceof ArmorMetaItem &&
player.inventory.armorInventory.get(getEquipmentSlot(armor).getIndex()).isEmpty() &&
!player.isSneaking()) {
player.inventory.armorInventory.set(getEquipmentSlot(armor).getIndex(), armor.copy());
player.setHeldItem(hand, ItemStack.EMPTY);
player.playSound(new SoundEvent(new ResourceLocation("item.armor.equip_generic")), 1.0F, 1.0F);
return ActionResult.newResult(EnumActionResult.SUCCESS, armor);
}
}

return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
}
}
12 changes: 12 additions & 0 deletions src/main/java/supersymmetry/api/items/IBreathingItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package supersymmetry.api.items;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import java.util.List;

public interface IBreathingItem {
boolean isValid(ItemStack stack, EntityPlayer player);

double tryTick(ItemStack stack, EntityPlayer player);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gregtech.api.unification.material.properties;
package supersymmetry.api.unification.material.properties;

import gregtech.api.unification.material.properties.PropertyKey;
import supersymmetry.api.unification.material.properties.SuSyPropertyKey;

import java.util.*;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/supersymmetry/api/util/SuSyDamageSources.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package supersymmetry.api.util;
import net.minecraft.util.DamageSource;

public class SuSyDamageSources {
private static final DamageSource SUFFOCATION = new DamageSource("suffocation").setDamageBypassesArmor();
private static final DamageSource TOXIC_ATMO = new DamageSource("toxic_atmo").setDamageBypassesArmor();

public static DamageSource getSuffocationDamage() {
return SUFFOCATION;
}

public static DamageSource getToxicAtmoDamage() {
return TOXIC_ATMO;
}
}
2 changes: 2 additions & 0 deletions src/main/java/supersymmetry/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import supersymmetry.common.blocks.SheetedFrameItemBlock;
import supersymmetry.common.blocks.SuSyBlocks;
import supersymmetry.common.blocks.SuSyMetaBlocks;
import supersymmetry.common.item.SuSyMetaItems;
import supersymmetry.loaders.SuSyFluidTooltipLoader;
import supersymmetry.loaders.SuSyIRLoader;

Expand Down Expand Up @@ -113,5 +114,6 @@ public static void registerModels(@NotNull ModelRegistryEvent event) {
public static void stitchTexture(TextureStitchEvent.Pre event) {
TextureMap map = event.getMap();
map.registerSprite(new ResourceLocation(Supersymmetry.MODID, "armor/jet_wingpack"));
SuSyMetaItems.armorItem.registerIngameModels(map);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package supersymmetry.client.renderer.handler;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.util.ResourceLocation;

import java.util.ArrayList;
import java.util.List;

import static supersymmetry.api.util.SuSyUtility.susyId;

public class BreathingApparatusModel extends ModelBiped {
public BreathingApparatusModel(String name, EntityEquipmentSlot slot) {
this.textureWidth = 64;
this.textureHeight = 64;

this.bipedHead.cubeList.clear();
this.bipedHeadwear.cubeList.clear();
this.bipedBody.cubeList.clear();
this.bipedRightArm.cubeList.clear();
this.bipedLeftArm.cubeList.clear();
this.bipedLeftLeg.cubeList.clear();
this.bipedRightLeg.cubeList.clear();

addChildren(name, slot);
}

public void addChildren(String name, EntityEquipmentSlot slot) {
switch (slot) {
case FEET -> {
this.bipedLeftLeg.addChild(modelForPart(name, "left_foot"));
this.bipedRightLeg.addChild(modelForPart(name, "right_foot"));
}
case CHEST -> {
this.bipedBody.addChild(modelForPart(name, "chest"));
this.bipedLeftArm.addChild(modelForPart(name, "left_arm"));
this.bipedRightArm.addChild(modelForPart(name, "right_arm"));
}
case LEGS -> {
this.bipedBody.addChild(modelForPart(name, "belt"));
this.bipedLeftLeg.addChild(modelForPart(name, "left_leg"));
this.bipedRightLeg.addChild(modelForPart(name, "right_leg"));
}
case HEAD -> this.bipedHead.addChild(modelForPart(name, "head"));
}
}

public ResourceLocation modelLocationFromPart(String armor, String model) {
return susyId("models/armor/" + armor + "_" + model + ".obj");
}

public OBJModelRender modelForPart(String armor, String model) {
return new OBJModelRender(this, modelLocationFromPart(armor, model), 17);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package supersymmetry.client.renderer.handler;

import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.List;

public interface ITextureRegistrar {
@SideOnly(Side.CLIENT)
List<ResourceLocation> getTextureLocations();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public class OBJModelRender extends ModelRenderer {
private int displayList;
private boolean compiled = false;
private IBakedModel objModel;
private float scaleMultiplier = 1F;

public OBJModelRender(ModelBase baseModel, ResourceLocation customModel, float scaleMultiplier) {
this(baseModel, customModel);
this.scaleMultiplier = scaleMultiplier;
}

public OBJModelRender(ModelBase baseModel, ResourceLocation customModel) {
super(baseModel);
Expand Down Expand Up @@ -109,7 +115,7 @@ public void render(float scale) {

private void compileDisplayList(float scale) {
if (this.scale == 0) {
this.scale = scale;
this.scale = scale * scaleMultiplier;
}

if (objModel == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package supersymmetry.client.renderer.handler;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.util.ResourceLocation;

import static supersymmetry.api.util.SuSyUtility.susyId;

public class SimpleBreathingApparatusModel extends ModelBiped {
public SimpleBreathingApparatusModel(String name, EntityEquipmentSlot slot) {
this.textureWidth = 64;
this.textureHeight = 64;

this.bipedHead.cubeList.clear();
this.bipedHeadwear.cubeList.clear();
this.bipedBody.cubeList.clear();
this.bipedRightArm.cubeList.clear();
this.bipedLeftArm.cubeList.clear();
this.bipedLeftLeg.cubeList.clear();
this.bipedRightLeg.cubeList.clear();

addChildren(name, slot);
}

public void addChildren(String name, EntityEquipmentSlot slot) {
switch (slot) {
case CHEST -> this.bipedBody.addChild(modelForPart(name, "tank"));
case HEAD -> this.bipedHead.addChild(modelForPart(name, "mask"));
}
}

public ResourceLocation modelLocationFromPart(String armor, String model) {
return susyId("models/armor/" + armor + "_" + model + ".obj");
}

public OBJModelRender modelForPart(String armor, String model) {
return new OBJModelRender(this, modelLocationFromPart(armor, model), 17);
}

}
5 changes: 4 additions & 1 deletion src/main/java/supersymmetry/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public static void registerBlocks(@NotNull RegistryEvent.Register<Block> event)
registry.register(SuSyBlocks.ELECTRODE_ASSEMBLY);
registry.register(SuSyBlocks.MULTIBLOCK_CASING);
registry.register(SuSyBlocks.SERPENTINE);
registry.register(SuSyBlocks.HARDBLOCKS);
registry.register(SuSyBlocks.CUSTOMSHEETS);

SHEETED_FRAMES.values().stream().distinct().forEach(registry::register);
}
Expand Down Expand Up @@ -115,7 +117,8 @@ public static void registerItems(@NotNull RegistryEvent.Register<Item> event) {
registry.register(createItemBlock(SuSyBlocks.ELECTRODE_ASSEMBLY, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.MULTIBLOCK_CASING, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.SERPENTINE, VariantItemBlock::new));

registry.register(createItemBlock(SuSyBlocks.HARDBLOCKS, VariantItemBlock::new));
registry.register(createItemBlock(SuSyBlocks.CUSTOMSHEETS, VariantItemBlock::new));

SHEETED_FRAMES.values()
.stream().distinct()
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/supersymmetry/common/EventHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@
import gregtech.api.util.TeleportHandler;
import gregtech.common.items.MetaItems;
import gregtechfoodoption.item.GTFOMetaItem;
import net.minecraft.block.BlockCauldron;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.boss.dragon.phase.PhaseHoldingPattern;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.management.PlayerList;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import supersymmetry.Supersymmetry;
import supersymmetry.api.SusyLog;
import supersymmetry.common.entities.EntityDropPod;
import supersymmetry.common.event.DimensionBreathabilityHandler;
import supersymmetry.common.event.MobHordePlayerData;
import supersymmetry.common.event.MobHordeWorldData;

@Mod.EventBusSubscriber(modid = Supersymmetry.MODID)
Expand Down Expand Up @@ -57,7 +69,7 @@ public static void onTrySpawnPortal(BlockEvent.PortalSpawnEvent event) {
}

@SubscribeEvent
public static void on(TickEvent.WorldTickEvent event) {
public static void onWorldTick(TickEvent.WorldTickEvent event) {

World world = event.world;

Expand All @@ -80,4 +92,11 @@ public static void on(TickEvent.WorldTickEvent event) {
mobHordeWorldData.markDirty();
}
}

@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.player.world.getTotalWorldTime() % 20 == 0 && event.phase == TickEvent.Phase.START) {
DimensionBreathabilityHandler.tickPlayer(event.player);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public BlockCoagulationTankWall(){
setResistance(10.0f);
setSoundType(SoundType.METAL);
setHarvestLevel("wrench", 2);
setDefaultState(getState(BlockCoagulationTankWall.CoagulationTankWallType.WOODEN_COAGULATION_TANK_WALL));
setDefaultState(getState(CoagulationTankWallType.WOODEN_COAGULATION_TANK_WALL));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

public class BlockSheetedFrame extends Block {

public static final PropertyEnum<BlockSheetedFrame.FrameEnumAxis> SHEETED_FRAME_AXIS = PropertyEnum.<BlockSheetedFrame.FrameEnumAxis>create("axis", BlockSheetedFrame.FrameEnumAxis.class);
public static final PropertyEnum<FrameEnumAxis> SHEETED_FRAME_AXIS = PropertyEnum.<FrameEnumAxis>create("axis", FrameEnumAxis.class);

public final PropertyMaterial variantProperty;

Expand All @@ -70,7 +70,7 @@ public BlockSheetedFrame(Material[] materials)
@Override @NotNull
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getStateFromMeta(meta).withProperty(SHEETED_FRAME_AXIS, BlockSheetedFrame.FrameEnumAxis.fromFacingAxis(facing.getAxis()));
return this.getStateFromMeta(meta).withProperty(SHEETED_FRAME_AXIS, FrameEnumAxis.fromFacingAxis(facing.getAxis()));
}

protected BlockStateContainer createStateContainer() {
Expand Down Expand Up @@ -99,9 +99,9 @@ public IBlockState withRotation(IBlockState state, Rotation rot)
switch (state.getValue(SHEETED_FRAME_AXIS))
{
case X:
return state.withProperty(SHEETED_FRAME_AXIS, BlockSheetedFrame.FrameEnumAxis.Z);
return state.withProperty(SHEETED_FRAME_AXIS, FrameEnumAxis.Z);
case Z:
return state.withProperty(SHEETED_FRAME_AXIS, BlockSheetedFrame.FrameEnumAxis.X);
return state.withProperty(SHEETED_FRAME_AXIS, FrameEnumAxis.X);
default:
return state;
}
Expand Down
Loading

0 comments on commit 4659c52

Please sign in to comment.