Skip to content

Commit

Permalink
Fix crash when IEOBJ items are inserted into AE2 inscribers, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
malte0811 committed Oct 28, 2023
1 parent 0801495 commit 1b3a986
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

import javax.annotation.Nonnull;

public interface BlockCallback<T> extends IEOBJCallback<T>
public interface BlockCallback<Key> extends IEOBJCallback<Key>
{
T extractKey(@Nonnull BlockAndTintGetter level, @Nonnull BlockPos pos, @Nonnull BlockState state, BlockEntity blockEntity);

T getDefaultKey();
Key extractKey(@Nonnull BlockAndTintGetter level, @Nonnull BlockPos pos, @Nonnull BlockState state, BlockEntity blockEntity);

default boolean dependsOnLayer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ default IEObjState getIEOBJState(Key key)
{
return new IEObjState(VisibilityList.showAll());
}

Key getDefaultKey();
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public ModelKey<T> getKey(
if(extraData.has(keyProperty))
key = extraData.get(keyProperty);
else
key = BlockCallback.castOrDefault(callback).getDefaultKey();
key = callback.getDefaultKey();
boolean includeLayer = BlockCallback.castOrDefault(callback).dependsOnLayer();
ShaderCase shader = extraData.get(CapabilityShader.MODEL_PROPERTY);
return new ModelKey<>(key, shader, includeLayer?layer: null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public IEObjState getIEOBJState(VisibilityList list)
{
return new IEObjState(list);
}

@Override
public VisibilityList getDefaultKey()
{
return VisibilityList.showAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class BuzzsawCallbacks implements ItemCallback<Key>
Expand Down Expand Up @@ -110,6 +111,12 @@ public Transformation getTransformForGroups(ItemStack stack, List<String> groups
null, null);
}

@Override
public Key getDefaultKey()
{
return new Key(Arrays.asList(null, null, null), false, false, false);
}

public record Key(List<ResourceLocation> bladeTexture, boolean hasQuiver, boolean oiled, boolean launcher)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import blusunrize.immersiveengineering.api.client.ieobj.ItemCallback;
import blusunrize.immersiveengineering.client.models.obj.callback.item.ChemthrowerCallbacks.Key;
import blusunrize.immersiveengineering.common.entities.illager.Bulwark;
import blusunrize.immersiveengineering.common.entities.illager.Fusilier;
import blusunrize.immersiveengineering.common.items.ChemthrowerItem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Quaternion;
Expand Down Expand Up @@ -66,6 +65,11 @@ public void handlePerspective(Key key, LivingEntity holder, TransformType camera
}
}

@Override
public Key getDefaultKey()
{
return new Key(false, false);
}

public record Key(boolean upgradedCapacity, boolean multitank)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.world.item.ItemStack;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.Supplier;

Expand Down Expand Up @@ -153,7 +154,15 @@ public static boolean shouldRotate(
transform==TransformType.THIRD_PERSON_RIGHT_HAND||transform==TransformType.THIRD_PERSON_LEFT_HAND);
}

public record Key(ResourceLocation headTexture, int damage, boolean waterproof, boolean oiled, boolean fortune)
@Override
public Key getDefaultKey()
{
return new Key(null, 0, false, false, false);
}

public record Key(
@Nullable ResourceLocation headTexture, int damage, boolean waterproof, boolean oiled, boolean fortune
)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public Vector4f getRenderColor(Key object, String group, String material, Shader
return new Vector4f(.067f, .067f, .067f, 1);
}

@Override
public Key getDefaultKey()
{
return new Key(new Vector4f(1, 1, 1, 1));
}

public record Key(Vector4f color)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public boolean shouldRenderGroup(Key key, String group, RenderType layer)
return true;
}

@Override
public Key getDefaultKey()
{
return new Key(0, false, false, false);
}

public record Key(int third_person_pass, boolean antenna, boolean induction, boolean tesla)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public void handlePerspective(Key key, LivingEntity holder, TransformType camera
}
}

@Override
public Key getDefaultKey()
{
return new Key(false, false);
}

public record Key(boolean scope, boolean speed)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ else if("frame".equals(groups.get(0))&&((Player)entity).containerMenu instanceof
return "frame".equals(groups.get(0))?matClose: matCylinder;
}

@Override
public Key getDefaultKey()
{
return new Key("", "", false, false, false, false, false, 0);
}

public record Key(
String elite, String flavor, boolean extraBullets, boolean fancyAnimation, boolean extraMelee,
boolean electro, boolean scope, int reload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ else if(cameraTransformType==THIRD_PERSON_LEFT_HAND)
}
}

@Override
public Key getDefaultKey()
{
return new Key(false, false);
}

public record Key(boolean flash, boolean shock)
{
}
Expand Down

0 comments on commit 1b3a986

Please sign in to comment.