Skip to content
This repository was archived by the owner on May 13, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ group = "mcp.mobius.waila"
archivesBaseName = "SoulShardsRespawn-forge"

minecraft {
mappings channel: "snapshot", version: "20200125-1.15.1"
mappings channel: 'snapshot', version: '20201028-1.16.3'

runs {
client {
Expand Down Expand Up @@ -65,7 +65,7 @@ processResources {
}

repositories {
maven { url "https://tehnut.info/maven" }
maven { url 'https://maven.tehnut.info' }
}

dependencies {
Expand Down Expand Up @@ -164,9 +164,7 @@ curseforge {

addGameVersion "Forge"

addGameVersion "1.15"
addGameVersion "1.15.1"
addGameVersion "1.15.2"
addGameVersion "1.16.4"

addArtifact sourcesJar
addArtifact apiJar
Expand Down
11 changes: 5 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
org.gradle.daemon=false
org.gradle.jvmargs=-Xmx3G

mc_version=1.15.2
forge_version=31.1.1
mapping_channel=snapshot
mapping_version=20200212-1.15.1
mc_version=1.16.4
forge_version=35.1.4
mcp_version=20201028-1.16.3

mod_version=1.2.0
mod_version=1.3.0
curse_id=291549

hwyla_version=1.10.8-B72_1.15.2
hwyla_version=1.10.11-B78_1.16.2
11 changes: 11 additions & 0 deletions src/main/java/info/tehnut/soulshardsrespawn/SoulShards.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import info.tehnut.soulshardsrespawn.core.util.JsonUtil;
import info.tehnut.soulshardsrespawn.item.ItemSoulShard;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemModelsProperties;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
Expand Down Expand Up @@ -43,5 +45,14 @@ public SoulShards() {
@SubscribeEvent
public void setupClient(FMLClientSetupEvent event) {
SoulShardsClient.initClient();
event.enqueueWork(this::registerPropertyOverride);
}

private void registerPropertyOverride() {
ItemSoulShard item = new ItemSoulShard();
ItemModelsProperties.registerProperty(item, new ResourceLocation(SoulShards.MODID, "bound"),
(stack, worldIn, entityIn) -> item.getBinding(stack) != null ? 1.0F : 0.0F);
ItemModelsProperties.registerProperty(item, new ResourceLocation(SoulShards.MODID, "tier"),
(stack, worldIn, entityIn) -> item.getBindingFloatValue(stack));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
public class SoulShardsClient {

public static void initClient() {
RenderTypeLookup.setRenderLayer(RegistrarSoulShards.SOUL_CAGE, RenderType.cutout());
RenderTypeLookup.setRenderLayer(RegistrarSoulShards.SOUL_CAGE, RenderType.getCutout());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public int getComparatorInputOverride(BlockState blockState, World world, BlockP
return (int) (((double) binding.getTier().getIndex() / ((double) Tier.INDEXED.size() - 1)) * 15D);
}

@Override
public boolean causesSuffocation(BlockState state, IBlockReader reader, BlockPos pos) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
Expand Down Expand Up @@ -99,17 +100,16 @@ private void spawnEntities() {
entityLiving.getPersistentData().putBoolean("cageBorn", true);
entityLiving.forceSpawn = true;

if (entityLiving.isAlive() && !hasReachedSpawnCap(entityLiving) && getWorld().func_226668_i_(entityLiving)) { // func_226668_i_ -> checkNoEntityCollision
if (entityLiving.isAlive() && !hasReachedSpawnCap(entityLiving) && getWorld().checkNoEntityCollision(entityLiving)) {
if (!SoulShards.CONFIG.getBalance().allowBossSpawns() && !entityLiving.isNonBoss())
continue;

CageSpawnEvent event = new CageSpawnEvent(binding, inventory.getStackInSlot(0), entityLiving);
if (MinecraftForge.EVENT_BUS.post(event))
continue;

getWorld().addEntity(entityLiving);
if (entityLiving instanceof MobEntity)
((MobEntity) entityLiving).onInitialSpawn(getWorld(), getWorld().getDifficultyForLocation(spawnAt), SpawnReason.SPAWNER, null, null);
((MobEntity) entityLiving).onInitialSpawn((ServerWorld) world, getWorld().getDifficultyForLocation(spawnAt), SpawnReason.SPAWNER, null, null);
break;
}
}
Expand Down Expand Up @@ -173,8 +173,8 @@ public void setState(boolean active) {
}

@Override
public void read(CompoundNBT tag) {
super.read(tag);
public void read(BlockState state, CompoundNBT tag) {
super.read(state, tag);

this.inventory.deserializeNBT(tag.getCompound("inventory"));
this.activeTime = tag.getInt("activeTime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

import info.tehnut.soulshardsrespawn.block.TileEntitySoulCage;
import info.tehnut.soulshardsrespawn.core.data.Binding;
import mcp.mobius.waila.api.*;
import mcp.mobius.waila.api.IComponentProvider;
import mcp.mobius.waila.api.IDataAccessor;
import mcp.mobius.waila.api.IEntityAccessor;
import mcp.mobius.waila.api.IEntityComponentProvider;
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.IRegistrar;
import mcp.mobius.waila.api.IWailaPlugin;
import mcp.mobius.waila.api.TooltipPosition;
import mcp.mobius.waila.api.WailaPlugin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.Color;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.registries.ForgeRegistries;
Expand Down Expand Up @@ -48,7 +57,7 @@ public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPl
if (entityEntry != null)
tooltip.add(new TranslationTextComponent("tooltip.soulshards.bound", entityEntry.getName()));
else
tooltip.add(new TranslationTextComponent("tooltip.soulshards.bound", binding.getBoundEntity().toString()).setStyle(new Style().setColor(TextFormatting.RED)));
tooltip.add(new TranslationTextComponent("tooltip.soulshards.bound", binding.getBoundEntity().toString()).setStyle(Style.EMPTY.setColor(Color.fromTextFormatting(TextFormatting.RED))));
}

tooltip.add(new TranslationTextComponent("tooltip.soulshards.tier", binding.getTier().getIndex()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.state.IProperty;
import net.minecraft.state.Property;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
Expand Down Expand Up @@ -153,9 +153,9 @@ public Set<BlockState> deserialize(JsonElement element, Type typeOfT, JsonDeseri
String[] stateValues = split[1].split(","); // Splits up each value
for (String value : stateValues) {
String[] valueSplit = value.split("=");
IProperty property = blockState.getProperty(valueSplit[0]);
if (property != null)
returnState = returnState.with(property, (Comparable) property.parseValue(valueSplit[1]).get());
Property prop = blockState.getProperty(valueSplit[0]);
if (prop != null && prop.parseValue(valueSplit[1]).isPresent())
returnState = returnState.with(prop, (Comparable) prop.parseValue(valueSplit[1]).get());
}
} else {
states.addAll(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(state)).getStateContainer().getValidStates());
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/info/tehnut/soulshardsrespawn/item/ItemSoulShard.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;;
import net.minecraft.item.ItemModelsProperties;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.MobSpawnerTileEntity;
import net.minecraft.util.*;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
Expand All @@ -41,15 +44,6 @@ public class ItemSoulShard extends Item implements ISoulShard {

public ItemSoulShard() {
super(new Properties().group(SoulShards.TAB_SS));

addPropertyOverride(new ResourceLocation(SoulShards.MODID, "bound"), (stack, worldIn, entityIn) -> getBinding(stack) != null ? 1.0F : 0.0F);
addPropertyOverride(new ResourceLocation(SoulShards.MODID, "tier"), (stack, world, entity) -> {
Binding binding = getBinding(stack);
if (binding == null)
return 0F;

return Float.parseFloat("0." + Tier.INDEXED.indexOf(binding.getTier()));
});
}

@Override
Expand Down Expand Up @@ -186,6 +180,14 @@ public Binding getBinding(ItemStack stack) {
return Binding.fromNBT(stack);
}

public float getBindingFloatValue(ItemStack stack) {
Binding binding = getBinding(stack);
if(binding == null) {
return 0F;
}
return Float.parseFloat("0." + Tier.INDEXED.indexOf(binding.getTier()));
}

public void updateBinding(ItemStack stack, Binding binding) {
if (!stack.hasTag())
stack.setTag(new CompoundNBT());
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/META-INF/mods.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"modLoader": "javafml",
"loaderVersion": "[26,)",
"loaderVersion": "[34,)",
"issueTrackerURL": "https://github.com/TehNut/Soul-Shards-Respawn/issues",
"displayURL": "https://github.com/TehNut/Soul-Shards-Respawn",
"license": "MIT License (https://github.com/TehNut/Soul-Shards-Respawn/blob/1.15_forge/LICENSE.md)"
"authors": "TehNut",
"mods": [
{
Expand All @@ -17,14 +18,14 @@
{
"modId": "forge",
"mandatory": false,
"versionRange": "[31,)",
"versionRange": "[34,)",
"ordering": "NONE",
"side": "BOTH"
},
{
"modId": "minecraft",
"mandatory": true,
"versionRange": "[1.15,)",
"versionRange": "[1.16.4,)",
"ordering": "NONE",
"side": "BOTH"
}
Expand Down