mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 16:27:45 +00:00
Change up how removing groups is done, should fix most issues
This commit is contained in:
1 parent
569cdee3b1
commit
48274f1e22
6 files changed
+72
-17
No files matched your search
@@ -2,8 +2,6 @@ package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* Represents a group of chiselable blocks.
|
||||
* <p>
|
||||
@@ -59,7 +57,7 @@ public interface ICarvingGroup {
|
||||
List<ICarvingVariation> getVariations();
|
||||
|
||||
/**
|
||||
* Adds a variation to this group.
|
||||
* Adds a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry.
|
||||
*
|
||||
* @param variation
|
||||
* An {@link ICarvingVariation} to add to this group
|
||||
@@ -67,13 +65,10 @@ public interface ICarvingGroup {
|
||||
void addVariation(ICarvingVariation variation);
|
||||
|
||||
/**
|
||||
* Removes a varaition with the passed {@link Block} and metadata from this group.
|
||||
* Removes a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry.
|
||||
*
|
||||
* @param block
|
||||
* The {@link Block} of the {@link ICarvingVariation variation}
|
||||
* @param metadata
|
||||
* The metadata of the {@link ICarvingVariation variation}
|
||||
* @return The ICarvingVariation that was removed. Null if nothing was removed.
|
||||
* @param variation
|
||||
* An {@link ICarvingVariation} to add to this group
|
||||
*/
|
||||
ICarvingVariation removeVariation(Block block, int metadata);
|
||||
boolean removeVariation(ICarvingVariation variation);
|
||||
}
|
||||
@@ -40,9 +40,33 @@ public interface ICarvingRegistry {
|
||||
void addVariation(String groupName, ICarvingVariation variation);
|
||||
|
||||
void addGroup(ICarvingGroup group);
|
||||
|
||||
|
||||
ICarvingGroup removeGroup(String groupName);
|
||||
|
||||
/**
|
||||
* Removes a varaition with the passed {@link Block} and metadata from the registry. If this variation is registered with mutiple groups, it will remove it from all of them.
|
||||
*
|
||||
* @param block
|
||||
* The {@link Block} of the {@link ICarvingVariation variation}
|
||||
* @param metadata
|
||||
* The metadata of the {@link ICarvingVariation variation}
|
||||
* @return The ICarvingVariation that was removed. Null if nothing was removed.
|
||||
*/
|
||||
ICarvingVariation removeVariation(Block block, int metadata);
|
||||
|
||||
/**
|
||||
* Removes a varaition with the passed {@link Block} and metadata from the registry, but only from the specified {@link ICarvingGroup} name.
|
||||
*
|
||||
* @param block
|
||||
* The {@link Block} of the {@link ICarvingVariation variation}
|
||||
* @param metadata
|
||||
* The metadata of the {@link ICarvingVariation variation}
|
||||
* @param group
|
||||
* The name of the group that the variation should be removed from
|
||||
* @return The ICarvingVariation that was removed. Null if nothing was removed.
|
||||
*/
|
||||
ICarvingVariation removeVariation(Block block, int metadata, String group);
|
||||
|
||||
void registerOre(String groupName, String oreName);
|
||||
|
||||
void setVariationSound(String name, String sound);
|
||||
|
||||
@@ -124,6 +124,16 @@ public class Carving implements ICarvingRegistry {
|
||||
ICarvingGroup g = groups.getGroupByName(groupName);
|
||||
return groups.remove(g) ? g : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation removeVariation(Block block, int metadata) {
|
||||
return removeVariation(block, metadata, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
|
||||
return groups.removeVariation(block, metadata, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariation(String groupName, Block block, int metadata, int order) {
|
||||
|
||||
@@ -4,8 +4,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
@@ -40,14 +38,14 @@ public class CarvingGroup implements ICarvingGroup {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation removeVariation(Block block, int metadata) {
|
||||
public boolean removeVariation(ICarvingVariation variation) {
|
||||
ICarvingVariation toRemove = null;
|
||||
for (ICarvingVariation v : variations) {
|
||||
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
|
||||
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
|
||||
toRemove = v;
|
||||
}
|
||||
}
|
||||
return toRemove == null ? null : variations.remove(toRemove) ? toRemove : null;
|
||||
return toRemove == null ? false : variations.remove(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -216,6 +216,30 @@ public class GroupList implements Set<ICarvingGroup> {
|
||||
return groups.keySet();
|
||||
}
|
||||
|
||||
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
|
||||
ICarvingGroup g = null;
|
||||
if (group != null) {
|
||||
g = groups.get(group);
|
||||
if (g == null) {
|
||||
throw new IllegalArgumentException("No such group " + group);
|
||||
}
|
||||
groups.remove(g.getName());
|
||||
}
|
||||
List<VariationWrapper> toRemove = Lists.newArrayList();
|
||||
for (VariationWrapper v : lookup.keySet()) {
|
||||
if ((g == null || lookup.get(v) == g) && v.v.getBlock() == block && v.v.getBlockMeta() == metadata) {
|
||||
if (g != null) {
|
||||
g.removeVariation(v.v);
|
||||
}
|
||||
toRemove.add(v);
|
||||
}
|
||||
}
|
||||
for (VariationWrapper v : toRemove) {
|
||||
lookup.remove(v);
|
||||
}
|
||||
return toRemove.isEmpty() ? null : toRemove.get(0).v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return groups.toString();
|
||||
|
||||
@@ -229,7 +229,11 @@ public class BlockMarblePaneRenderer implements ISimpleBlockRenderingHandler {
|
||||
if (iconPane == null || iconTop == null || iconSide == null)
|
||||
return false;
|
||||
|
||||
paneRenderer.set(x, y, z, iconPane, iconTop, iconSide);
|
||||
if (renderer.hasOverrideBlockTexture()) {
|
||||
paneRenderer.set(x, y, z, renderer.overrideBlockTexture, renderer.overrideBlockTexture, renderer.overrideBlockTexture);
|
||||
} else {
|
||||
paneRenderer.set(x, y, z, iconPane, iconTop, iconSide);
|
||||
}
|
||||
|
||||
boolean connectsNorth = block.canPaneConnectToBlock(world.getBlock(x, y, z - 1));
|
||||
boolean connectsSouth = block.canPaneConnectToBlock(world.getBlock(x, y, z + 1));
|
||||
|
||||
Reference in new issue
Block a user