-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
232 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/ | ||
docsOut/ | ||
run/ |
29 changes: 7 additions & 22 deletions
29
src/main/java/com/blamejared/contenttweaker/VanillaFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 58 additions & 2 deletions
60
src/main/java/com/blamejared/contenttweaker/items/CoTItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,71 @@ | ||
package com.blamejared.contenttweaker.items; | ||
|
||
import com.blamejared.contenttweaker.items.functions.*; | ||
import com.blamejared.contenttweaker.items.wrappers.*; | ||
import com.blamejared.crafttweaker.impl.blocks.*; | ||
import com.blamejared.crafttweaker.impl.entity.player.*; | ||
import com.blamejared.crafttweaker.impl.item.*; | ||
import mcp.*; | ||
import net.minecraft.block.*; | ||
import net.minecraft.entity.*; | ||
import net.minecraft.entity.player.*; | ||
import net.minecraft.inventory.*; | ||
import net.minecraft.item.*; | ||
import net.minecraft.util.math.*; | ||
import net.minecraft.world.*; | ||
import net.minecraftforge.common.*; | ||
|
||
import javax.annotation.*; | ||
import java.util.*; | ||
|
||
|
||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
public class CoTItem extends Item { | ||
|
||
public CoTItem(MCItemRepresentation representation) { | ||
super(representation.getProperties().createInternal()); | ||
private final Map<ToolType, ToolTypeFunction> toolClasses; | ||
private final ToolDestroySpeedFunction speedFunction; | ||
|
||
public CoTItem(MCItemProperties properties) { | ||
super(properties.createInternal()); | ||
this.toolClasses = properties.getToolClasses(); | ||
this.speedFunction = properties.destroySpeedFunction; | ||
} | ||
|
||
@Override | ||
public int getHarvestLevel(ItemStack stack, ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState blockState) { | ||
|
||
if(!toolClasses.containsKey(tool)) { | ||
return -1; | ||
} | ||
final MCPlayerEntity playerEntity = player != null ? new MCPlayerEntity(player) : null; | ||
final MCBlockState state = blockState != null ? new MCBlockState(blockState) : null; | ||
return toolClasses.get(tool) | ||
.getHarvestLevel(new MCItemStackMutable(stack), new MCToolType(tool), playerEntity, state); | ||
} | ||
|
||
@Override | ||
public float getDestroySpeed(ItemStack stack, BlockState state) { | ||
return speedFunction.getDestroySpeed(new MCItemStackMutable(stack), new MCBlockState(state)); | ||
} | ||
|
||
@Override | ||
public Set<ToolType> getToolTypes(ItemStack stack) { | ||
return toolClasses.keySet(); | ||
} | ||
|
||
@Override | ||
public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { | ||
if(getMaxDamage(stack) == 0) { | ||
return false; | ||
} | ||
|
||
if(!worldIn.isRemote && state.getBlockHardness(worldIn, pos) != 0.0F) { | ||
stack.damageItem(1, entityLiving, (livingEntity) -> { | ||
livingEntity.sendBreakAnimation(EquipmentSlotType.MAINHAND); | ||
}); | ||
} | ||
|
||
return true; | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
src/main/java/com/blamejared/contenttweaker/items/MCItemRepresentation.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/main/java/com/blamejared/contenttweaker/items/expand/ExpandMCBlockState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.blamejared.contenttweaker.items.expand; | ||
|
||
import com.blamejared.contenttweaker.items.wrappers.*; | ||
import com.blamejared.crafttweaker.api.annotations.*; | ||
import com.blamejared.crafttweaker.impl.blocks.*; | ||
import org.openzen.zencode.java.*; | ||
|
||
@ZenRegister | ||
@ZenCodeType.Expansion("crafttweaker.api.block.MCBlockState") | ||
public class ExpandMCBlockState { | ||
|
||
@ZenCodeType.Getter("harvestTool") | ||
@ZenCodeType.Method | ||
public static MCToolType getHarvestTool(MCBlockState _this) { | ||
return new MCToolType(_this.getInternal().getHarvestTool()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/blamejared/contenttweaker/items/functions/ToolDestroySpeedFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.blamejared.contenttweaker.items.functions; | ||
|
||
import com.blamejared.crafttweaker.api.annotations.*; | ||
import com.blamejared.crafttweaker.api.item.*; | ||
import com.blamejared.crafttweaker.impl.blocks.*; | ||
import com.blamejared.crafttweaker.impl.item.*; | ||
import org.openzen.zencode.java.*; | ||
|
||
@ZenRegister | ||
@FunctionalInterface | ||
@ZenCodeType.Name("mods.contenttweaker.item.ToolDestroySpeedFunction") | ||
public interface ToolDestroySpeedFunction { | ||
|
||
@ZenCodeType.Method | ||
float getDestroySpeed(IItemStack stack, MCBlockState state); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/blamejared/contenttweaker/items/functions/ToolTypeFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.blamejared.contenttweaker.items.functions; | ||
|
||
import com.blamejared.contenttweaker.items.wrappers.*; | ||
import com.blamejared.crafttweaker.api.annotations.*; | ||
import com.blamejared.crafttweaker.api.item.*; | ||
import com.blamejared.crafttweaker.impl.blocks.*; | ||
import com.blamejared.crafttweaker.impl.entity.player.*; | ||
import org.openzen.zencode.java.*; | ||
|
||
@ZenRegister | ||
@FunctionalInterface | ||
@ZenCodeType.Name("mods.contenttweaker.item.ToolTypeFunction") | ||
public interface ToolTypeFunction { | ||
@ZenCodeType.Method | ||
int getHarvestLevel(IItemStack stack, MCToolType type, @ZenCodeType.Nullable MCPlayerEntity playerEntity, @ZenCodeType.Nullable MCBlockState state); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 41 additions & 11 deletions
52
src/main/java/com/blamejared/contenttweaker/items/wrappers/MCItemProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.